本机滚动动画如何反应?

时间:2020-10-05 17:10:54

标签: javascript react-native animation android-animation react-native-flatlist

希望大家都过得愉快。 我是react-native的初学者,只是无法理解滚动动画的工作 有人可以解释一下这个动画的工作原理吗?

const scrollX = useRef(new Animated.Value(0)).current;

scrollX的值是否更改或保持不变,如果保持不变,则插值的工作原理

let inputRange = [
   (index - 1) * width,
    index * width,
    (index + 1) * width
];
const imageScale = scrollX.interpolate({
    inputRange,
    outputRange: [0, 1, 0],
});

以及此Animated.event的作用

onScroll={Animated.event(
    [{ nativeEvent: { contentOffset: { x: scrollX } } }],
    { useNativeDriver: true },
)}

感谢您的时间!

0 个答案:

没有答案