2017-08-06 5 views
0

私は反応ネイティブでプレイしていますが、トランジションのアニメーションに問題があります。リアクションネイティブのアニメーショントランジションが正しく動作しません。

Windows 10 - Hyper V、ビジュアルコードエミュレータAndroid - Ignite Boilerplate。

私が何をしようとしている

私がクリックすると、私はクリック位置の0から2までのスケールアニメーションの円を表示したいです。

は(私が最初のフレームを参照するにはsetTimoutを入れている)以下の画像を参照してください:私が持っているもの

。最初のクリックでは、コンポーネントは自然な幅と高さで非常に素早く表示されますが、0,001のスケールは効果がありません。その後、0,001〜2のスケールでアニメーションが開始されます。

その他のクリックで、円は前の円の寸法で最初のフレームを開始します。アニメーションが開始されます。しかしもう一度、スケール:0は最初のフレームで効果がありません。

The start of the animation take the data of the last called component

ここでランチ画面のコードです:

export default class LaunchScreen extends Component { 
    state = { 
    clicks: [] 
    }; 
    handlePress(evt) { 
    console.log(evt.nativeEvent.locationX, evt.nativeEvent.locationY) 
    let xCoord = evt.nativeEvent.locationX; 
    let yCoord = evt.nativeEvent.locationY; 
    this 
     .state 
     .clicks 
     .push({x: xCoord, y: yCoord}); 
    this.setState({clicks: this.state.clicks}); 
    } 
    renderClick() { 
    if (this.state.clicks.length > 0) { 
     return this 
     .state 
     .clicks 
     .map((item, i) =>< ClickAnimation key = { 
      item.x 
     } 
     x = { 
      item.x 
     } 
     y = { 
      item.y 
     } />) 
    } else { 
     return <View/> 
    } 

    } 

    render() { 
    return (
     <View style={styles.container}> 
     <ScrollView 
      style={styles.scrollView} 
      horizontal={true} 
      showsHorizontalScrollIndicator={true} 
      contentContainerStyle={styles.scrollView}> 
      <TouchableWithoutFeedback 
      style={styles.touchableWithoutFeedback} 
      onPress= 
      {evt => this.handlePress(evt)}> 
      <View style={styles.scrollView}> 
       {this.renderClick()} 
      </View> 
      </TouchableWithoutFeedback> 
     </ScrollView> 
     </View> 
    ) 
    } 
} 

そして、ここでは、円のコンポーネント:

import React from 'react'; 
import PropTypes from 'prop-types'; 
import {Animated, View, Easing} from 'react-native'; 

export default class ClickAnimation extends React.Component { 
    constructor() { 
     super(); 
     console.log(this.state) 
     this.state = { 
      scaleAnim: new Animated.Value(0.001); 
     }; 
    } 
    componentDidMount() { 

     Animated 
      .timing(this.state.scaleAnim, { 
      toValue: 2, 
      duration: 2000 
     }) 
      .start(); 
     .scaleAnim 
    } 
    render() { 
     return (<Animated.View 
      style={{ 
      zIndex: 10, 
      borderColor: "blue", 
      borderRadius: 400, 
      borderWidth: 1, 
      position: "absolute", 
      top: this.props.y, 
      left: this.props.x, 
      width: 60, 
      height: 60, 
      backgroundColor: "red", 
      transform: [ 
       { 
        scaleY: this.state.scaleAnim 
         ? this.state.scaleAnim 
         : 0 
       }, { 
        scaleX: this.state.scaleAnim 
         ? this.state.scaleAnim 
         : 0 
       } 
      ] 
     }}/>); 
    } 
} 

あなたはなぜそうなのかアイデアを持っていますか?

答えて

0

解決策が見つかりました。私はそれを見ていた

https://github.com/facebook/react-native/issues/6278

と私は0001を書いた理由です:

これは、この問題が付属しています。しかし、0,001はまだ少しです。 0,01で素晴らしい作品です。

だから、答えは次のとおりです。

、それはあまりにも少しあったので、ちょうど0.01で0.001を交換してください。

関連する問題