私は、テキストの色をアニメーション化しようとしている。このようなものだ:はネイティブアニメーションネイティブドライバサポートカラー/のbackgroundColorを反応させていますか?
const animateTest = scrollY.interpolate({
inputRange: [0, 100],
outputRange: ['rgba(255,0,0,1)', 'rgba(0,255,0,1)']
});
return (<View>
<Animated.Text style={{ position:'absolute',
color: animateTest
}} >blah blah blah</Animated.Text>
<Animated.ScrollView
scrollEventThrottle={16}
onScroll={Animated.event(
[
{
nativeEvent: {contentOffset: {y: scrollY}},
},
],
{
useNativeDriver: true,
}
)}
>
が、私はこのエラーを取得しています:
ReactNative 0.44.0に従って使用して
Style property 'color' is not supported by native animated module
彼らが言うのでthis blog post に動作するようになっています:
Not everything you can do with Animated is currently supported in Native Animated. The main limitation is that you can only animate non-layout properties, things like transform, opacity and backgroundColor will work but flexbox and position properties won't.
しかし、私はサポートされているコード内のスタイルのためのホワイトリストがある参照してください。link to relevant code 非常に限られたホワイトリストがある:色が含まれていません/ backgroundColorの
誰も助けることができる
const STYLES_WHITELIST = {
opacity: true,
transform: true,
/* legacy android transform properties */
scaleX: true,
scaleY: true,
translateX: true,
translateY: true,
};
私はここにいる - それはサポートされるべきかどうか?
こんにちは、あなたの答えに感謝。それは正しく動作します。しかし、小さな修正が必要です。ルートの高さを機能させるには、position: 'absolute'をその子の1つに設定するだけで済みます。 – asubanovsky