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

AnimationExperimental: Animated node does not respond to onPress event #1678

Closed
ivanbabanov opened this issue Jun 18, 2015 · 3 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ivanbabanov
Copy link

Hello!
In my project I need an animated items falling down the screen and user should be able to tap on it. I've used AnimationExperemental Library and animation runs perfect, but item does not respond to onPress event until animation is completed.

Item for animation is described as class:

var AnimItem = React.createClass({
  getInitialState: function(){
    //console.log("getInitialState called "+ this.props.ref);
    return(
        { bubble1_img : require('image!bubble3'),
          bubbleStyle: {backgroundColor:'rgba(0,0,0,0)', opacity: 1, width: 102, borderRadius: 51} }
      );
  },
  bubbleClick: function(){
    console.log("Bubble tapped private");
  },
  render: function(){
        return(
        <View style={ this.state.animItemStyle } ref={ this.props.ref }>
        <TouchableHighlight onPress={ ()=>{console.log('Pressed');} }  style={{ borderRadius: 51, height:102, width: 102, borderWidth:1 , borderColor:'red' }}>
        <Image source={this.state.item_img} style={{ width: 100, height: 100, borderRadius: 50 }}/>

        </TouchableHighlight>
        <Text> {this.props.bubname} </Text>
        </View>
      );
  }
});

Animation is called:

AnimationExperimental.startAnimation({
  node: itemRef,
  duration: 10000,
  easing: 'easeInQuad',
  property: 'positionY',
  fromValue: 0,
  toValue: 1000,}, this.animCallback( itemRef ));

So, maybe I'm wrong in used way and there isa another way to make an item animated and responsible for onPress/tap/click events?

@brentvatne
Copy link
Collaborator

AnimationExperimental uses CoreAnimation and the animations occur in the presentation layer so this breaks hit detection. You can use it for static animations right now, but this api is deprecated and I'd recommend using react-tween-state until the new api is release (soon!).

@ivanbabanov
Copy link
Author

Thanks you for fast response. I had the same thoughts but I was need a confirmation from expert. Is my understanding correct that react-tween-state will solve my problem and it will not block hit detection during the animation?

@brentvatne
Copy link
Collaborator

@ivanbabanov - correct! it should work just fine with that :)

@facebook facebook locked as resolved and limited conversation to collaborators Jun 19, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 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

3 participants