2016-05-15 80 views
0

我在使用Animated.decay從onPanResponderRelease處理程序中獲取速度,並將其饋送到我的React Native應用程序中的「向下拖動以解除」手勢衰變。在Animated.decay中配置速度以忽略輕拂手勢的視圖

唯一的,這是我真的不明白我的速度和減速應該是什麼。我無法理解這些值的含義。我輸入的任何值(無論是從onPanResponderReleasegesturestate.vy還是我手動輸入的靜態值)都不會導致流體動畫,視圖會立即消失。

我和值這樣打下去

Animated.decay(this.props.dismissVal, { 
    velocity: 0.03, 
    deceleration: 0.997 
}); 

而且dismissVal使用像

top: this.props.dismissVal.interpolate({ 
    inputRange: [0, 1], 
    outputRange: [0, _containerLayout.height] 
}) 

我已經看了很多在react-native-animated-tinder例如,沒有運氣。我很難理解速度(和減速)的值應該是什麼樣子。

回答

0

不要忘記開始腐爛。 Animated.decay({...}).start();

而第二個錯誤,可以嘗試改變this.props的。所有傳遞給組件的道具,只能在父組件中更改。在你的子組件中,它是最終的變量。

//constructor 
this.state = { animatedValue: new Animated.Value() } 
.... 
.... 
Animated.decay(this.state.animatedValue, {...}).start();