moschan / react-native-flip-card

The card component which has a motion of flip for React Native(iOS/Android)
MIT License
390 stars 108 forks source link

How do you specify the duration of the animation flip? #58

Open gianpaj opened 6 years ago

gianpaj commented 6 years ago

Thanks for putting this component together!

If you can even show me where to add this prop I'll be happy to send a pull request. Thanks

mr-piratman commented 6 years ago

not possible in this version. try to copy and past out of node_module. and add the props manually like so: if FlipCard line 50 Animated.spring(this.state.rotate, { toValue: Number(isFlipped), tension: this.props.tension, friction: this.props.friction, useNativeDriver: this.props.useNativeDriver }

kevinNejad commented 6 years ago

spring animation doesnt get duration. You can change the aniamtion to Animated.timing as follows: Animated.timing(this.state.rotate, { toValue: Number(isFlipped), duration:this.props.duration, useNativeDriver: this.props.useNativeDriver } ).start((param) => { this.setState({isFlipping: false}) this.props.onFlipEnd(this.state.isFlipped) }) }

*If you'd like to use long duration (longer than 1000) you may need to animate content change as well, as theyre now changed once you click on the card. you can do it by changing the fipping time to half of the duration, e.g. if your duration is 1000, then the flipping should be 500, _animation (isFlipped) { if (!this.timer) { this.timer = setTimeout(() => { this.setState({isFlipped: !this.state.isFlipped}) this.timer = null }, 500) } You can set this value manually if all of your Flliping card behave the same.

just make sure you extends your node modules, otherwise, you'd lose the change when you remove and install node modules again. Hope it helps