2017-11-09 8 views
2

私はSETPARAMSReact Native同じアニメーションイベントで2つのイベントを渡す方法は?

componentWillMount() { 
        this.props.navigation.setParams({ 
        animatedValue: this._animatedValue.interpolate({ 
        inputRange: [0, 800], 
        outputRange: [0, -70], 
        extrapolate: 'clamp' 
        }), 
        colorRange: this.x.interpolate({ 
        inputRange: [0, 5,10,15,20,25,30,35,40,49,56], 
        outputRange: ['rgba(0, 0, 0,0)', 'rgba(255, 0, 0,0.1)', 'rgba(255, 0, 0,0.2)', 'rgba(255, 0, 0,0.3)', 'rgba(255, 0, 0,0.4)', 'rgba(255, 0, 0,0.5)', 'rgba(255, 0, 0,0.6)', 'rgba(255, 0, 0,0.7)', 'rgba(255, 0, 0,0.8)', 'rgba(255, 0, 0,0.9)' ,'rgba(255, 0, 0,1)'], 
        extrapolate: 'clamp' 
        }) 
       }); 
       } 

と私の唯一の使用中のアニメーションイベントを通過した二つの作用を持っています。私は縦にスクロールするときどのように私は両方のイベントを使用することができます

<ScrollView onScroll={ Animated.event([{nativeEvent: {contentOffset: {y: this._animatedValue }}}])} scrollEventThrottle={16} > 

答えて

1

Animated.eventは、あなたが望むように多くの引数を受け入れ、あなたがそれにnativeEventまたはカスタムリスナーを渡すので、のは、これを試してみましょう:

<ScrollView onScroll={ Animated.event(
    [{nativeEvent: {contentOffset: {y: this._animatedValue }}}], 
    { listener: this._customListener }, 
)} scrollEventThrottle={16}> 

そして、

_customListener(e) { 
    // do whatever you want using this.colorRange 
} 
+0

確かに、この回答にあなたが求めていたものをマークしていただけますか? @BeingExpert – adielhercules

+0

私はそれを試みましたが、イベントの1つだけが受け入れられ、このようにすると私のプログラムは非常に遅くなりました。 –

関連する問題