Я бы использовал обещание, чтобы установить свою анимацию, я попытался создать цепочки обещаний, чтобы высвободить новое значение моей анимации.Однако консоль возвращает меня:
_this.setExitAnimation не определен. Вот мой фрагмент кода activJS:
/***** HERE TRIGGER THE setAnimation's PROCESS THEN INJECT
UPDATED ANIATION IN COMPONENT *****/
textAnimation=()=>{
// CALL THE PROMISE'S CHAIN
this.setState({elementType:"text"},
() => this.routeAnimationPosition
.then((anim) => {
console.log("promise resolved: ", anim)
// set new animations
this.setState({firstLineAnimation:anim},
() => console.log("after setState textAnimation: ", this.state.textAnimation)
)
{...}
/***** HERE START THE PROMISE'S CHAIN TO UPDATE ANIMATION'S NAME *****/
routeAnimationPosition= new Promise((resolve, reject)=>{
console.log("in routeAnimationPosition")
if(this.state.exitLoop){
this.setExitAnimation.then((anim)=> resolve(anim));
}else{
this.setEnterAnimation.then((anim)=> resolve(anim));
}
})
setEnterAnimation=new Promise((resolve, reject)=>{
console.log("in setEnterAnimation")
if(this.state.elementType ==="text"){
if(this.state.currentView % 2 === 0){
this.setState({textAnimation:enterDownAnimation});
resolve(enterDownAnimation);
{...}
Я не могу понять, что не так, мне кажетсямой процесс анимации честный, любой намек был бы отличным, спасибо