【发布时间】:2017-08-18 17:40:41
【问题描述】:
我对 Animated.event 的滚动事件有插值的问题。当我将 Animated.event 与
一起使用时useNativeDriver: true
我收到下一个错误:
Style property 'height' is not supported by native animated module
如果我使用 opacity 属性 - 它工作正常。
我的代码:
render() {
this.yOffset = new Animated.Value(0);
let event = Animated.event([
{
nativeEvent: {
contentOffset: {
y: this.yOffset
}
}
}
], {useNativeDriver: true});
let opacity = this.yOffset.interpolate({
inputRange: [0, 120],
outputRange: [1, 0],
});
let height = this.yOffset.interpolate({
inputRange: [0, 180],
outputRange: [200, 100],
});
return (
<View>
<Header
style={{
opacity,
height
}}
/>
<ScrollView
style={[
{
flexDirection: "column"
}
]}
scrollEventThrottle={1}
onScroll={event}
>
// some content
</ScrollView>
</View>
);
}
opacity - 有效。
height - 没用。
没有useNativeDriver: true - 一切正常。
Android Accelerated_x86 API 23
RN 0.43.0-rc.4
反应 16.0.0-alpha.3
RN 0.42 中也存在问题。
【问题讨论】:
-
你还有同样的问题吗? :D
标签: android reactjs animation react-native