Как я могу сбросить анимацию в response-native-animatable при смене реквизита? - PullRequest
1 голос
/ 30 октября 2019

Я бы хотел сбросить анимацию и переиграть при смене реквизита, но сначала он работает только один раз. Я использовал библиотеку реагировать на нативную анимацию npm и не смог найти решение для сброса анимации.

Это мой код с анимацией.

import * as Animatable from 'react-native-animatable';

function ResetAnimation (changeAnimation) {
   const zoomAnimation = {
    0: {
      scale: 1
    },
    0.5: {
      scale: 2
    },
    1: {
      scale: 1
    }
  };
  return (
    <View>
       <Animatable.View animation = {zoomAnimation}>
         <View>
          // At first it works well but next no animation.
          .......
         </View>
       </Animatable.View>
    </View>
 );
}

Помоги мне.

1 Ответ

1 голос
/ 30 октября 2019

Вы можете определить анимацию как состояние:

construstor(props){
  super(props)
  this.state = {
     zoomAnimation = {
    0: {
      scale: 1
    },
    0.5: {
      scale: 2
    },
    1: {
      scale: 1
    }
  }
   }
}

// then use it in the view
<Animatable.View animation = {this.state.zoomAnimation}>
         <View>
          // At first it works well but next no animation.
          .......
         </View>
       </Animatable.View>

// when you want reset it, you call this.setState,
this.setState({
zoomAnimation = {
    0: {
      scale: 1
    },
    0.5: {
      scale: 2
    },
    1: {
      scale: 1
    }
  }

})
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...