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

android PanResponder not work with view which not have backgroundColor #21749

Closed
grean opened this issue Oct 12, 2018 · 4 comments
Closed

android PanResponder not work with view which not have backgroundColor #21749

grean opened this issue Oct 12, 2018 · 4 comments
Labels
API: PanResponder Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@grean
Copy link

grean commented Oct 12, 2018

Same issue as #1889

React Native Environment Info:
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 4.52 GB / 15.86 GB
Binaries:
Yarn: 1.5.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5014246

"react": "16.5.0",
"react-native": "0.57.1",

here is my code :

import React, { Component } from 'react';
import { StyleSheet, Text, View, PanResponder, ScrollView } from 'react-native';

export default class Test extends Component {
constructor(props) {
super(props)
this.state = {
infoLocation: "infoLocation",
infoPage: "infoPage",
infoTarget: "infoTarget",
infoLocationMove: "infoLocationMove",
infoPageMove: "infoPageMove",
infoTargetMove: "infoTargetMove",
};

this._panResponder = PanResponder.create({
  // Ask to be the responder:
  onStartShouldSetPanResponder: (evt, gestureState) => true,
  onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
  onMoveShouldSetPanResponder: (evt, gestureState) => true,
  onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,

  onPanResponderGrant: (evt, gestureState) => {
    // The gesture has started. Show visual feedback so the user knows
    // what is happening!
    const infoLocation =`infoLocation X:${evt.nativeEvent.locationX}, Y:${evt.nativeEvent.locationY}`
    const infoPage = `infoPage X:${evt.nativeEvent.pageX}, Y:${evt.nativeEvent.pageY}`
    const infoTarget = `infoTarget ${evt.nativeEvent.target}`
    this.setState({ infoLocation, infoPage, infoTarget });
    // gestureState.d{x,y} will be set to zero now
  },
  onPanResponderMove: (evt, gestureState) => {
    // The most recent move distance is gestureState.move{X,Y}
    const infoLocationMove = `infoLocationMove X:${evt.nativeEvent.locationX}, Y:${evt.nativeEvent.locationY}`
    const infoPageMove = `infoPageMove X:${evt.nativeEvent.pageX}, Y:${evt.nativeEvent.pageY}`
    const infoTargetMove = `infoTargetMove ${evt.nativeEvent.target}`
    this.setState({ infoLocationMove, infoPageMove, infoTargetMove });
    // The accumulated gesture distance since becoming responder is
    // gestureState.d{x,y}
  },
  onPanResponderTerminationRequest: (evt, gestureState) => true,
  onPanResponderRelease: (evt, gestureState) => {
    // The user has released all touches while this view is the
    // responder. This typically means a gesture has succeeded
  },
  onPanResponderTerminate: (evt, gestureState) => {
    // Another component has become the responder, so this gesture
    // should be cancelled
  },
  // onShouldBlockNativeResponder: (evt, gestureState) => {
  //   // Returns whether this component should block native components from becoming the JS
  //   // responder. Returns true by default. Is currently only supported on android.
  //   return true;
  // },
});

}

render() {
return (
<View style={styles.container} {...this._panResponder.panHandlers}>


test



{this.state.infoLocation}
{this.state.infoPage}
{this.state.infoTarget}
{this.state.infoLocationMove}
{this.state.infoPageMove}
{this.state.infoTargetMove}


);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
},
dayContainer: {
display: 'flex',
flexDirection: "row",
alignItems: "stretch",
alignContent: 'stretch',
justifyContent: 'center',
height: 50,
// backgroundColor: 'transparent', ------>>>> if you remove the comment it will work when your click near the text 'test' and not only on the text component.
},
halfText: {
color: 'black',
alignSelf: 'center',
},
containerInfo: {
flex: 1,
},
infoText: {
color: 'black',
alignSelf: 'center',
},
});

Hope it helps :)

@yinhangfeng
Copy link

you need to set collapsable=false
http://facebook.github.io/react-native/docs/view.html#collapsable

hugo-amino referenced this issue in hugo-amino/react-native-video-controls Jan 3, 2019
Touchable container for dragging seekbar collapses in Android, which leaves only the small circle surface to be dragged.
Issue as described here: https://github.com/facebook/react-native/issues/21749\#issuecomment-429315753
hugo-amino referenced this issue in booxmedialtd/react-native-video-controls Jan 3, 2019
Touchable container for dragging seekbar collapses in Android, which leaves only the small circle surface to be dragged.
Issue as described here: https://github.com/facebook/react-native/issues/21749\#issuecomment-429315753
@stale
Copy link

stale bot commented Jan 16, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 24, 2019
@hramos hramos removed the Bug Report label Feb 6, 2019
@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Aug 9, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 9, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API: PanResponder Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

4 participants