[Android] onResponderMove nativeEvent locationX does not change
Hey guys,
Running into a bug (on Android only) where locationX of onResponderMove never changes as you drag along the view.
var MyComponent = React.createClass({
onStartShouldSetResponder: function(e) {
return true;
},
onMoveShouldSetResponder: function(e) {
return true;
},
onResponderMove: function(e) {
var evt = e.nativeEvent;
console.log(evt.locationX);
},
render: function() {
return (
<View
style={styles.box}
onStartShouldSetResponder={this.onStartShouldSetResponder}
onMoveShouldSetResponder={this.onMoveShouldSetResponder}
onResponderMove={this.onResponderMove}>
</View>
);
}
});
var styles = StyleSheet.create({
box: {
flexDirection: 'row',
alignSelf: 'center',
width: 200,
height: 50,
backgroundColor: 'red'
}
});
React Native 0.22.0 OSX
@facebook-github-bot bugfix
Confirming this is a bug. Took time last night to dig in and narrowed the problem down to these 2 lines. For some reasons the subtraction of the 2 floats only happens on first touch and not during the entire interaction. What's strange is console logging those two values separately shows that both update throughout the entire touch interaction.
Will look into it a bit more.
/cc @dmmiller Thoughts?
Example https://rnplay.org/apps/i0rjeQ
Hey @erickreutz, we're a small team and rely on the community to fix issues that don't affect fb apps. If you're sure this is a bug can you send a pull request with a fix?
This is a bug. I have an internal bug to fix it but haven't gotten to it yet. If you'd like to send a pull request to fix it, I'm happy to check it out.
@dmmiller Whats the issue?
We just haven't fixed it. I just mean to let you know that I know about it.
Ah I see, I thought you might of known what was causing that bug.
Honestly, I haven't looked into it yet. Too many other things to look at. If you want to dive in and see, that would be great :)
What's happening is the the two values you are trying to subtract to get locationX and locationY both increment/decrement in parallel so the subtracted value is always going to be the same.
Not sure if I'll have the time to send a PR for this one. As a work around I've just been calculating my own locationX with pageX minus the x origin of the target view.
Was this ever able to be fixed? My hack is broken now onLayout has the x origin of the view as 0 in the 0.28
So sad. We encountered the same issue in 0.29 version.
Still seeing in 0.30.0.
@erickreutz
onLayout is returning the page offset correctly for me as of 0.30.0 so I'm able to use your hack to work.
confirm this is still happening in 0.32.1
following code is sufficient to reproduce it:
<View
onTouchMove={(e) => {console.log('touchMove', e.nativeEvent)}}
style={{flex: 1}}
/>
Can confirm, happening on 0.33.0.
Still seeing in 0.35.0
the trouble is that in
float targetViewCoordinateX = motionEvent.getX() - event.getViewX();
the motionEvent.getX() changes (when dragging) while event.getViewX() stays the same and denotes when the touch started. These coordinates are assigned once and continue to be passed here.
Still seeing this on 0.40
Still exists on 0.41.2. any plan to fix it ?