J'ai commencé à animer une image dans mon projet réac-natif mais de toute façon je ne peux pas animer la propriété blurRadius
. Translate
et Scale
fonctionnent très bien. Voici le code que j'utilise pour interpolat
valeurs e pour le flou, l'échelle et traduis:Animer la propriété blurRadius avec react-native
// Compute image position
const imageTranslate = this.state.scrollY.interpolate({
inputRange: [-IMAGE_MAX_HEIGHT, 0, IMAGE_MAX_HEIGHT],
outputRange: [IMAGE_MAX_HEIGHT/2, 0, -IMAGE_MAX_HEIGHT/3],
extrapolate: 'clamp',
});
// Compute image blur
const imageBlur = this.state.scrollY.interpolate({
inputRange: [0, IMAGE_MAX_HEIGHT],
outputRange: [0, 100],
extrapolate: 'clamp',
});
// Compute image scale
const imageScale = this.state.scrollY.interpolate({
inputRange: [-IMAGE_MAX_HEIGHT, 0, IMAGE_MAX_HEIGHT],
outputRange: [2, 1, 1],
extrapolate: 'clamp',
});
Et ceci est mon image:
return (
<Animated.Image
blurRadius={imageBlur}
source={this.props.imgSrc}
style={[
animatedImageStyles.backgroundImage,
{ transform: [{ translateY: imageTranslate }, { scale: imageScale }] }
]}
/>
);
Je binded la valeur this.state.scrollY
sur un rouleau ScrollView
.
L'animation de blurRadius fonctionne en 0.51 mais je rencontre des problèmes de performance avec Android en particulier. – 30secondstosam