Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PanResponder > onPanResponderMove doesn't work with Animated.event() if called inside a function #15880

Closed
xardit opened this issue Sep 10, 2017 · 1 comment
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@xardit
Copy link

xardit commented Sep 10, 2017

I have the following examples:

WORKS

// moving
onPanResponderMove: Animated.event([null, {
  dx: this.state.pan.x, // x,y are Animated.Value
  dy: this.state.pan.y,
}]),

DOESN'T WORK

// moving
onPanResponderMove: (evt, gestureState) => {
  this.props.updatePanPosition(gestureState.moveX, gestureState.moveY)

  return Animated.event([null, {
    dx: this.state.pan.x,
    dy: this.state.pan.y,
  }])
},

The pan state is an Animated.ValueXY()
I need to use the onPanResponderMove function to get latest coordinates on the screen and use it in another component

This looks like an issue!

I'm using react-native: 0.47.2

@xardit
Copy link
Author

xardit commented Sep 10, 2017

Never mind, fixed it
Reason was because Animation.event() only generates the function which is used from onPanResponderMove, it also needs the default arguments evt, gestureState

WORKING CODE

// moving
onPanResponderMove: (evt, gestureState) => {
  this.props.updatePanPosition(gestureState.moveX, gestureState.moveY)

  return Animated.event([null, {
    dx: this.state.pan.x,
    dy: this.state.pan.y,
  }])(evt, gestureState)
},

@xardit xardit closed this as completed Sep 10, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Sep 10, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants