【发布时间】:2018-08-07 12:04:59
【问题描述】:
我有一个使用动画事件的 ScrollView 来做一些基本的动画。一切都很好,但现在我想在图像上为 blurRadius 设置动画,但直到滚动开始几秒钟后,模糊才会开始。我已经尝试了几乎所有可能的动画解决方案...
这是 ScrollView...(AnimatedEvent.scrollYOffset 只是我做的一个快捷功能)(通常我的油门在 16,但发现 7 稍微好一点,但还差一点)
<ScrollView
onScroll={AnimatedEvent.scrollYOffset(animY)}
scrollEventThrottle={7}
style={[QuickStyle.fillScreen,{
backgroundColor: 'rgb(16, 50, 74)',
flex: 1,
}]}>
这是具有模糊属性的图像之一...
const blurry = this.state.animY.interpolate({
inputRange: [0,150],
outputRange: [0,7],
extrapolate: 'clamp'
});
const slide1 = <View style={[{
borderRadius: borderRadius,
overflow: 'hidden',
width: width,
height: height,
backgroundColor: 'rgb(28, 181, 251)' //light blue
}]}>
<Animated.Image blurRadius={blurry} ref={img => this.blur1 = img} style={{
width: width,
height: height,
}} source={require('../../assets/images/big-numbers.jpg')} />
</View>;
我尝试过的...(都具有相同的滞后波涛汹涌的结果)1)直接动画到blurRadius道具2)使用带有setNativeProps({blurRadius:x})的ref 3)使用setState({blurRadius: x}) - 这至少很流畅,但会大大降低每个动画的速度。
接下来我要尝试什么... 在发布模式下运行这 3 个解决方案。我也会考虑直接在 Objective-C 中执行此操作,但我真的想避免这种情况...
react-native-blur 包会有帮助吗?我猜不是……
请帮忙!谢谢!
【问题讨论】:
-
仍在寻找更好的答案。我正在使用本机驱动程序...仍然没有运气!
标签: javascript ios objective-c reactjs native