在Android 5.1上的物理設備上運行RN v0.40.0。我試圖動畫文本出現淡入和以下列方式向上滑動:在動畫中反應原生android崩潰
export default class Example extends PureComponent {
constructor(props) {
super(props);
this.translate = new Animated.Value(-15);
this.fade = new Animated.Value(0);
}
componentWillReceiveProps() {
setTimeout(() => {
Animated.timing(this.translate, {
toValue: 0,
duration: 800,
easing: Easing.inOut(Easing.ease),
}).start();
Animated.timing(this.fade, {
toValue: 1,
duration: 800,
easing: Easing.inOut(Easing.ease),
}
).start();
}, 150);
}
render() {
return (
<View>
<Animated.View
style={{
transform: [
{translateY: this.translate},
],
opacity: this.fade
}}
>
<Text>
{this.props.text}
</Text>
</Animated.View>
</View>
);
}
後,我從開發菜單加載JS包,並轉到該視圖的應用程序崩潰,沒有錯誤日誌,有時顯示Application ... stopped working
,有時不顯示。如果我再次從android菜單啓動應用程序,它會加載好,僅在第一次崩潰。它肯定與動畫有關,因爲在我推出動畫之前我沒有崩潰。沒有日誌,沒有線索,請給我一些建議,那可能是什麼,我應該嘗試什麼以及我應該檢查什麼。謝謝。
順便說一句,關於該視圖與動畫我有一個相當沉重的背景圖像(〜400k)可能是一個問題?
UPD:我已經把範圍縮小到它,當我試圖並行運行的動畫,無論是與setTimeout
或Animation.parallel
崩潰。可能是什麼問題呢?
非常感謝!非常有用的信息。但不幸的是,即使一次只動畫一個元素,我也會崩潰... –
在文檔中,他們將Animated.Value初始化爲'this.state = {pan:new Animated.ValueXY(),};'--no在父母的爭論;不知道你的負面價值是否是一個問題 – kwishnu
不,不幸的是這不是問題 –