Git Product home page Git Product logo

react-native-swipe-gestures's People

Contributors

dgrcode avatar fmauquie avatar glepur avatar ifiokjr avatar jeffgukang avatar sverps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-swipe-gestures's Issues

onPress, onClick, onSelect is missing

onPress event missing.
Is there any way to get onPress/onClick callback from child component of <GestureRecognizer/>
e.g

<GestureRecognizer
         onSwipeLeft={state => this.onSwipeLeft(state)}
         onSwipeRight={state => this.onSwipeRight(state)}
         config={config}
       >
     <TouchableOpacity  onPress={this.onViewClick.bind(this)}>
       <Text >{this.props.text}</Text>
     </TouchableOpacity>     
  </GestureRecognizer>

OR

<GestureRecognizer
          onSwipeLeft={state => this.onSwipeLeft(state)}
          onSwipeRight={state => this.onSwipeRight(state)}
          onPress={this.onViewClick.bind(this)}
          config={config}
        >
        <Text >{this.props.text}</Text>
  </GestureRecognizer>

block your child's events

<GestureRecognizer
velocityThreshold={0.1}
onSwipeDown={(state) => this.onSwipeDown(state)}
style={style}>
{this.state.myText}
onSwipe callback received gesture: {this.state.gestureName}
{MyCustomView}
{MyHorizontalScroll}

Now i can not listening when i scrolling my scrollview :(

Provide the original synthetic event to gesture event handlers

I'm working in a user case in which I need to stopPropagate the event in the swipe right event handler, but it's not in the payload received (which is just gestureState).

Since this is a high level event, I don't know if it's correct to just use the event that the Pan Responder sends, but it may be useful at the very least to have something like a "getOriginalEvent" method on the new Synthetic Event created for this new event, or some solution like that.
Let's discuss it.

I can workaround it with a internal state, but it will be cool to have access to the synthetic event object.

Let me know if you're interested I can create a PR.

Passing in Options

Would be great if you could override these from outside the class:

const swipeConfig = {
  velocityThreshold: 0.3,
  directionalOffsetThreshold: 80
};

Swipe in modal issue

Ive implemented swipe-gestures in parts of my app, but had issues in a modal. I found this issue and it seems like there is no real concrete solution. But then I realized I am also using React-Native-Snap-Carousel and swipe works just fine in the modal. Any idea what the difference is?

How to add GestureRecongnizer to whole page?

Hi sorry I looked through whole Read me but I wasn't able to determine how to do it, I've a modal which I show on clicking button(using react-native-navigation by wix), it was all working well but when I added GestureRecongnizer to it, the modal won't pop up. I get the following log in my console:

React: Got DOWN touch before receiving UP or CANCEL from last gesture

Following is my code:
renderLoadingView() { return ( <GestureRecognizer onSwipeDown={() => closeModal()} config={SWIPE_CONFIG}> <View style={styles.loading} > <Text> {this.state.loadingText} </Text> </View> </GestureRecognizer> ); }

I need to add detect swipe down action on whole page if there is a better place please let me know.

Swipe Gesture component breaks ScrollView

I have a ScrollView wrapped in a <GestureRecognizer> component. The Swipe action works great, but the scroll view stopped scrolling properly. It's very glitchy and hardly detects scroll events.

Multiple Swipe Left required to swipe Left

HI,
I have horizontal gallery and when swipe left it not happens in one swipe . I need multiple swipe to get it work.
Please look into the issue.

<GestureRecognizer
onSwipeLeft={() => {
let currentPosition = this.state.currentPosition;
if (this.state.alreadyVoted == true) {
currentPosition = this.state.nextVotingPosition
}
if (currentPosition < this.state.contentList.length - 1) {
this.setState({
currentPosition: currentPosition + 1,
contentId: this.state.contentList[currentPosition + 1],
alreadyVoted: false
})
console.log('Displaying next item - ', currentPosition)
} else {
console.log('No more items to display!!')
this.setState({
currentPosition: currentPosition + 1,
alreadyVoted: false
})

                                        }
                                        this.saveLastViewedContentForCampaign(
                                            this.state.campaignId,
                                            currentPosition + 1)
                                    }}
                                    config={{
                                        detectSwipeUp: false,
                                        detectSwipeDown: false,
                                        detectSwipeRight: false,
                                        velocityThreshold: 0.3,
                                        directionalOffsetThreshold: 80
                                    }}>{this.renderGallery(tabVerticalStyles)}
                                </GestureRecognizer>

Prevent unused directions being blocked.

Hi there,

I am making good use of the package at the moment however there seems to be an 'issue' or in my case likely an oversight. Most situations I am only applying a behaviour to one or 2 of the directions available, for example I am making use of left and right swipe in conjunction with a sliding pane component, however the gestures are blocking the regular up and down ScollView/ListView from being able to scroll up and down (forces them to 2 fingers). Even though I am omitting anything to do with the Swipe Up & Down, it seems those are still reserved (for lack of a better word) by the package regardless of whether they are used or not.

Is there a way to free up the unused gestures to perform their normal behaviour?

Thanks

Unable to comprehend the meanbing of "velocityThreshold", "directionalOffsetThreshold" and "gestureIsClickThreshold" in config

I was going through React-Native-swipe docs where they have written something like this

velocityThreshold: Number 0.3 Velocity that has to be breached in order for swipe to be triggered (vx and vy peroperties of gestureState)

directionalOffsetThreshold: Number 80 Absolute offset that shouldn't be breached for swipe to be triggered (dy for horizontal swipe, dx for vertical swipe)

For some reason I am unable to comprehend, Like if the number is greater than 0.3 means that the user needs to swipe harder (with greater velocity)

and same goes for directionalOffsetThreshold

Pass through of up/down motion while capturing left/right?

Great component, thank you so much. Works great. I am wondering, is there any way to pass through the up/down gestures while capturing the left/right gestures with your component? I ask because I would like a ListView on the screen that can still be naturally scrolled up and down but capture a left/right swipe to change sections..

ListViews don't scroll inside of GestureRecognizer on iOS

The same code works fine on android, but when I put a scrollview inside of the GestureRecognizer the scrolling is interrupted and it only moves a fraction of an inch.

  <GestureRecognizer
          onSwipeLeft={(state) => this.onSwipeLeft(state)}
          onSwipeRight={(state) => this.onSwipeRight(state)}
  >
     <ListView
             dataSource={this.dataSource}
             renderRow={this.renderRow.bind(this)}
            />
  </GestureRecognizer>

Swipe does not work on Android

i was trying to implemented this lib to my project and it works perfectly fine on iOS but doesn't work on Android. Is this lib is for iOS only??

Blocking Touch

Does this terminate the touch? It seems that if you put a button inside the GestureRecognizer it stops working.

works on iOS, but not Android

The swipe gestures work perfectly on iOS, yet on Android, it doesn't work. The action will fire randomly when swiping.. maybe once every 10-20 swipe attempts?

Any suggestions or solutions?

Thank you.

Detect start of swipe?

Is there a way to detect the start of a swipe?

I would love to be able to attach a listener to the Recognizer.

Gesture recognizer inside gesture recognizer doesn't work

I have a gesture recognizer inside a view. Inside that view there's a button that opens a modal. Inside that modal I have another gesture recognizer.

Whenever I'm swiping on the gesture recognizer inside the modal view, the handles in the parent gesture recognizer are called.

Is this the expected behaviour or am I doing something wrong? Can I do anything to have the gesture recognizer in the modal receive the touches instead of the parent gesture recognizer?

GestureRecognizer inside of a TouchableWithoutFeedback with OnPress prop stops swipe gestures

Just putting this out there to see if anyone else is seeing the same response. I had the GestureRecognizer inside of a TouchableWithoutFeedback with an onPress prop and that stopped the GestureRecognizer from recognizing any swipes.

<TouchableWithoutFeedback
    onPress={() => Keyboard.dismiss()}>
    <View>
        <GestureRecognizer
            onSwipe={(direction, state) => this.onSwipe(direction, state)}>
            ...
        </GestureRecognizer>
    </View>
</TouchableWithoutFeedback>

Debugging showed that the gestureState was:

{
    dx: 0
    dy: 0
    moveX: 0
    moveY: 0
    numberActiveTouches: 1
    stateID: 0.3603969835877927
    vx: 0
    vy: 0
    x0: 0
    y0: 0
    _accountsForMovesUpTo: 0
}

And this was the response every time I tried to swipe.

I don't fully understand why, but just wanted to see if anyone else was getting the same response.

Swipe gesture return null direction value on IOS

Here is the detail

<GestureRecognizer
                onSwipe={(direction, state) => this.onSwipe(direction, state, item)}
For Onswipe 
    onSwipe(gestureName, gestureState, item) {
        console.log("direction is="+gestureName);
        let { outletInfo, assetFilter, tags, imageOlderThanHrs, locationClassification, market, imageStatus } = this.state;
        const { SWIPE_LEFT, SWIPE_RIGHT } = swipeDirections;
        let paramsObj = {
            AssetPurityId: item.AssetPurityId ? item.AssetPurityId : 0,
            AssetId: item.AssetId
        };
        switch (gestureName) {
            case SWIPE_LEFT:
                Object.assign(paramsObj, { PrevNext: 1 });
                break;
            case SWIPE_RIGHT:
                Object.assign(paramsObj, { PrevNext: -1 });
                break;
        }

Gatting null direction in starting 3-4 attempt

Doesn't seem to work on Modals

Added this to a modal, not registering any gesture, up, down, left, or even right...

Currently running version 1.0.5 on React Native version 0.63.2

Strange detection area

Hi, I have a component defined like this prerry much

<View style={{flex: 1, alignItems: 'stretch'}}>
	<View style={{flex: 92}}>
		<GestureRecognizer onSwipeLeft={this.showNext} onSwipeRight={this.showPrevious} config={config} style={{flex: 1}}>
			<View style={{flex: 93, alignItems: 'stretch'}}>
				<View style={{flex: 18}}/>
				<View style={{flex: 9, alignItems: 'center'}}>
					<Image source={LOGO} style={{flex:1, resizeMode: 'contain'}}/>
				</View>
				<View style={{flex: 11}}/>
				<View style={{flex: 62}}>
					{this.getTab()}
				</View>
			</View>
			<View style= {{flex: 7, alignItems: 'center', justifyContent: 'center'}}>
				<View style={{flexDirection: 'row'}}>
					<View style={{height: circleSize, width: circleSize, marginRight: 5, borderRadius: circleSize / 2, backgroundColor: this.getDotBackground(0)}}/>
					<View style={{height: circleSize, width: circleSize, borderRadius: circleSize / 2, backgroundColor: this.getDotBackground(1)}}/>
					<View style={{height: circleSize, width: circleSize, marginLeft: 5, borderRadius: circleSize / 2, backgroundColor: this.getDotBackground(2)}}/>
				</View>
			</View>
		</GestureRecognizer>
	</View>
	<View style={{flex: 8, backgroundColor: 'rgb(23,168,104)', alignItems: 'center', justifyContent: 'center'}}>
		<Text style={[Styles.buttonTextAttributes]}>SALTA</Text>
	</View>
</View>

Essentially it is a bigger view with most of the content and a view on the bottom that will act like a button and I want to catch the swipes on the bigger view. Where I call the getTab function I got some code to render inside (an image and some text, nothing incredible here). The strange thing is that by default the GestureRecognizer seems to stop to grab the swipes after the last component returned by the getTab function, and also it seems to not be able to get it on the three view on the bottom (essentially they are three view shaped like a dot), even if they are all inside the GestureRecognizer.
The strange thing is that if I set a background on the gesture recognizer I see it is filling the expected area and also it starts to catch the swipes correctly. As workaround for now I use a transparent background, like
<GestureRecognizer onSwipeLeft={this.showNext} onSwipeRight={this.showPrevious} config={config} style={{flex: 1, backgroundColor: 'rgba(255,0,0,0)'}}>

and like this it seems to works, but there is something strange happening there.

The main code sample in React Hooks

Hi, here is the same code as used in the code sample but with React Hooks:

import React, {Component} from 'react';
import {Text} from 'react-native';
import GestureRecognizer, {swipeDirections} from 'react-native-swipe-gestures';
 
export default function TestFile(){
    const [myText, setMyText] = React.useState('I\'m ready to get swiped!');
    const [gestureName, setGestureName] = React.useState('none');
    const [backgroundColor, setBackgroundColor] = React.useState('#fff');
 
  const onSwipeUp = (gestureState) => {
    setMyText('You swiped up!');
  }
 
  const onSwipeDown = (gestureState) => {
    setMyText('You swiped down!');
  }
 
  const onSwipeLeft = (gestureState) => {
    setMyText('You swiped left!');
  }
 
  const onSwipeRight = (gestureState) => {
    setMyText('You swiped right!');
  }
 
  const onSwipe = (gestureName, gestureState) => {
    const {SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT} = swipeDirections;
    setGestureName(gestureName);
    switch (gestureName) {
      case SWIPE_UP:
        setBackgroundColor('red');
        break;
      case SWIPE_DOWN:
        setBackgroundColor('green');
        break;
      case SWIPE_LEFT:
        setBackgroundColor('blue');
        break;
      case SWIPE_RIGHT:
        setBackgroundColor('yellow');
        break;
    }
  }
 
  const config = {
    velocityThreshold: 0.3,
    directionalOffsetThreshold: 80
  };

  return (
    <GestureRecognizer
      onSwipe={(direction, state) => onSwipe(direction, state)}
      onSwipeUp={(state) => onSwipeUp(state)}
      onSwipeDown={(state) => onSwipeDown(state)}
      onSwipeLeft={(state) => onSwipeLeft(state)}
      onSwipeRight={(state) => onSwipeRight(state)}
      config={config}
      style={{
        flex: 1,
        backgroundColor: backgroundColor,
      }}
      >
      <Text>{myText}</Text>
      <Text>onSwipe callback received gesture: {gestureName}</Text>

    </GestureRecognizer>
  );
}

Swiping doesn't work over MapView on IOS

onSwipe events doesn't fire when used over react-native-maps on IOS. It works fine on Android.

example code
<GestureRecognizer onSwipeLeft={() => props.navigation.navigate('app.explorecollectionview')} onSwipeRight={() => props.navigation.goBack()} style={{flex: 1}}> <MapView ref={ref => _map = ref} ........./> </GestureRecognizer >

Is there any solution to this problem. Am I doing something wrong. Any workaround i may apply please guide!

Gesture recognizer inside of a rn camera working only when background color is set to something

Hey, I was making kinda like a snapchat app and used rncamera to show the camera on the whole screen, I tried different configurations but gesture recognizer only works when its background color is set to some color, otherwise it does not.

Also when i try to place gesture recognizer above all the other elements then it only works on a small distance around the text which displays onSwipe callback recieved gesture

this is the rendered part :
``
<View style={{flex: 1, flexDirection: 'row', alignItems: 'stretch',backgroundColor: 'black'}}>

<RNCamera ref={ref=> { this.camera = ref; }} style = {styles.preview} type={this.state.cameraType}   flashMode={this.state.flash} autoFocus={this.state.autoFocus} mirrorImage={this.state.mirrorMode} permissionDialogTitle={'Permission to use camera'} permissionDialogMessage={'We need your permission to use your camera phone'} onGoogleVisionBarcodesDetected={({ barcodes }) => { console.log(barcodes) }} >  
    <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'center', alignItems: 'stretch', }}>  
        <GestureRecognizer onSwipeLeft={(state)=> this.onSwipeLeft(state)} config={config} style={{ flex: 1, backgroundColor: None, }} >  
            <Text>{this.state.myText}</Text>  
            <Text>onSwipe callback received gesture: {this.state.gestureName}</Text>  
            <View style={styles.blehh}>  
                <View style={{flex: 1, flexDirection: 'row'}}>
                    <TouchableOpacity onPress={ this.changeCameraType.bind(this)} style={ [this.state.cameraType=='back' ?styles.backButton:styles.backButtonNew,{marginLeft: '1%'}]}>
                        <Icon name={ "camera"} size={16} color={this.state.cameraType=='back' ? "#ffff": '#000'} />
                    </TouchableOpacity>
                </View>
                <View style={{flex: 1}}>
                    <TouchableOpacity onPress={ this.takePicture.bind(this)} style={ styles.capture}>
                    </TouchableOpacity>
                </View>
                <View style={{flex: 1, flexDirection: 'row'}}>
                    <TouchableOpacity onPress={ this.changeFlashType.bind(this)} style={ [this.state.flashActive?styles.flashOnButton:styles.backButton,{marginLeft: '23%'}]}>
                        <Icon name={ "bolt"} style={{ color: this.state.flashActive? '#000': '#fff'}}size={28} />
                    </TouchableOpacity>
                </View>
            </View>
        </GestureRecognizer>
    </View>
</RNCamera>
``

Any help on how to make gesture swipe cover the whole screen without background color will be appreciated

Recognizing Horizontal Swiping

Hi @glepur. I am having trouble triggering onSwipe for horizontal swipe gestures. I have used default config parameters

const config = {
      velocityThreshold: 0.3,
      directionalOffsetThreshold: 100
    };

I have messed around altering params but still cannot reliable horizontal swipe when using ios simulator.

Could you provide more context on the range of velocityThreshold and directionalOffsetThreshold

Swipe gesture blocks range bar swipe

I have the react-native-video-controls over a video, i want to implement some swipe events to change the video source. I manage to make this work. However i am now unable to swipe the volume down or even move the seek bar. Hope i can find any help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.