-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Touch event is canceled on small move because element height is 0 #157
Comments
Also getting the same conclusion here. The BugSummary: All move related touch behavior functions incorrectly with react-native-svg. I created a demo project to demo this: Here is a GIF: You can see that in this sequence:
The expected behavior is Technical DetailsThis line in RN's Touchable determines whether the touch moved out of the view boundary or not. If the touch moved out of the boundary, To perform this calculate, Touchable mixin saves the size and position of the element it is attached to to compare them to the touch event position. The measurement is done through This is particularly bad for 3D Touch enabled devices. When combining a Force Touch device (6s, 6s Plus, 7, 7 Plus) with an app that targets 9.0 and below. Due to an iOS SDK 9.0 bug, Force change triggers SuggestionsI would like to hear @magicismight's input on this, some options are:
I'm more than happy to help here with the code. |
Any update on this? |
Not that I know of. One workaround, which cripple's touch moved event, but makes onPress: [[your press handler]]
onResponderMove: function() { return; } |
Similar to the above comment, if you only care about the onPress event not touchMove events, you can explicitly use the onPressIn (or onPressOut). In testing it appeared to be slightly more responsive than having the onPanResponder just return. |
If you use the svg in a scroll view, it is very easy to trigger the touch out event if the user starts scrolling from the svg. So be extra careful with it. |
Any update on this? The reason I'm using svg is to get non-rectangular buttons, specifically in a scroll view. Once one svg element has failed to register an onPress event, then no other svg element will register presses until the scroll view is reloaded. The workaround of setting onResponderMove to NOPs on the SVG elements doesn't seem to work, maybe because of how the scroll view works? Is there any other workaround I can attempt? |
My first reaction is this is going to be hard. I haven't checked with the
newer RN version but AFAIK the detection for touch move out in RN assums
the element is rectangular, which doesn't work for you here.
On Fri, Dec 2, 2016 at 8:01 AM Daniel Dunér ***@***.***> wrote:
Any update on this?
The reason I'm using svg is to get non-rectangular buttons, specifically
in a scroll view.
[image: left-right-buttons]
<https://cloud.githubusercontent.com/assets/148074/20839812/42e8865e-b8ae-11e6-839d-07b5b91c91af.png>
Once one svg element has failed to register an onPress event, then no
other svg element will register presses until the view is reloaded.
The workaround of setting onResponderMove to NOPs on the SVG elements
doesn't seem to work, maybe because of how the scroll view works? Is there
any other workaround I can attempt?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAH3M-a3OMZq2DocDH14bCmIPRXZf5lVks5rEECPgaJpZM4KTj5B>
.
--
Chengyin
|
Just to be clear, I already have this working:
It works perfectly fine most of the time. But because of (presumably) this bug, the svg elements completely stop responding sometimes. Definitely after a pressIn -> tiny move -> pressOut, though maybe also at other times (it's difficult to tell) So if this bug was fixed that would solve my problem, right? |
Has there been any progress or new insights on this issue? We are currently also facing the issue. We are working around it by using the |
I also have this issue through victory-native which uses this library. Is anyone working on it? Seems reasonably breaking. |
My situation is like @GeeWee, this could be a critical problem. |
I have also the same problem. onPressIn and onPressOut does not work, because I use svg inside a panresponder. I probably need to do the hit-detection myself, as it seems to be broken on android |
possible workaround: instead of the viewboundary, we could check the speed or distance of the touches like in a panresponder and tolerate small moves. This would fix the problem in many cases. |
i debugged it a little and i am very confused now: If i touch down and move the finger, onPressOut is called immediatly. But contrary to what @chengyin said, touchableHandleResponderMove is not called then and isTouchWithinActive is not called. That's why you can't even manipulate the hitbox with pressRetentionOffset or hitSlop. Instead touchableHandleResponderTerminate is called immediatly. I could not find out yet, why this happens. Maybe it happens when the svg is inside a panresponder or so. |
Hey @macrozone, I don't really know why |
@chengyin you are correct. I have overwritten I tried to get around this issue here by playing with different threshold in onMoveShouldSetPanResponderCapture, but i realized that there are even more bugs in the android version of react-native-svg. If you have a panresponder attached on a view around an svg, you will get odd jumps in movements (dx and dy) and speeds (vx, vy) when you move your finger over the view. If you log the gestureState (second argument) in onMoveShouldSetPanResponderCapture you will even notice that dx and dy do not start with 0 as they should! I am trying to work around this nasty issue for days now, but the more I found out, the more bugs arise 👎 Edit: this Issue here might lead to this "jumping" behaviour: #433 |
Has anyone found a solution to this. I'm drawing little graphs with SVG inside a horizontal ScrollView so they can be panned. My targets on bar graphs (for example) are huge, if my finger drifts at all or rolls even I don't get on I could probably figure out a fix using the |
I posted a fix here: https://github.com/FormidableLabs/victory-native/issues/25 |
@chengyin I think I've fixed the underlying issue now, try with the latest commit in the master branch and this code: import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
TouchableWithoutFeedback,
} from 'react-native';
import Svg, { Rect, Text as SvgText } from 'react-native-svg';
export default class touchesMove extends Component {
constructor(props) {
super(props);
this.state = { event: 'Last press event will be shown here.' };
this.handlers = {
onPress: () => {
this.setEvent('onPress');
},
onPressIn: () => {
this.setEvent('onPressIn');
},
onPressOut: () => {
this.setEvent('onPressOut');
},
};
}
setEvent(event) {
this.setState({ event });
}
render() {
return (
<View style={styles.container}>
<Svg width={200} height={200}>
<Rect fill="navy" width={300} height={500} {...this.handlers} />
<SvgText x={0} y={14} fill="#fff">
{'react-native-svg <Rect>'}
</SvgText>
</Svg>
<TouchableWithoutFeedback {...this.handlers}>
<View style={styles.demo}>
<Text style={styles.text}>{'react-native <View>'}</Text>
</View>
</TouchableWithoutFeedback>
<Text>{this.state.event}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
},
demo: {
width: 200,
height: 200,
backgroundColor: 'orange',
},
text: { color: 'white' },
}); |
@msand I haven’t done RN development for a while now and I no longer have the SDKs installed. So I can’t help with the testing here, unfortunately. Feel free to utilize the testing repo I posted. It should contain all code needed. |
FWIW I installed the latest version |
@jnicholls Oh, I wonder if I've introduced a regression after having fixed this, could you try with this commit (the latest one when I wrote the previous comment) ad99f97 |
@jnicholls I have a fix for android: e2e415c |
@msand Thank you, I will check these out for sure. In the meantime I implemented onResponderMove, onPressIn and onPressOut and am doing my own calculation to determine if the user is tapping or dragging their finger (in a scroll-like fashion) which is working quite well as a JS workaround. |
any news here? If it's not been tested, I can do it. Let us know :) |
Can you try this fix? (for iOS) 2f51350 |
I think I have (gesture) interactions between native animated transforms and normal svg transforms working correctly now as well: 8c05da0 |
I think this should be fixed now, closing until further notice. |
On galaxy s6 touch is so sensitive that when you tap on the phone sometimes move event is fired. And because height in
TouchableMixin._handleQueryLayout
is 0 so because of thatisTouchWithinActive
will always be false and touch event will be canceled.Now I am not sure how to fix because I am not sure how react-native is getting that value from the native component. Any help is appreciated
The text was updated successfully, but these errors were encountered: