Is it possible for .transitionTo() to return a promise like the predefined animations do?
i.e
This works
this.refs.component.fadeOut(200).then( () => {} );
Whereas this throws 'Possible Unhandle Promise Rejection
this.resf.component.transitionTo({opacity: 0}, 200, 'linear').then( () => {} );
Would be great to have this feature.
Currently I'm using a timeout after my transition to do the trick. Any better suggestion ?
Hey guys, I started a project with react-native-animatable. It's a fantastic library. And this feature will be very welcome.
I'm not sure if this is the best way to make it, but I've been using it for some time now and have not experienced any problems. The feature counts the number of completed iterations and triggers the promise. It does not use 'setTimeout'.
I've created a fork at https://github.com/vramosx/react-native-animatable with this feature.
With this, we can use:
this.refs.objectRef.transitionTo({ opacity: 0 }).then(() => alert('Hey! Transition ends!'));
or:
this.refs.objectRef.transition({opacity: 1}, { opacity: 0 }).then(() => alert('Hey! Transition ends!'));
@oblador If it is a good solution and you want to add to the original, feel free to. I'm happy to help.
@vramosx Thanks for making this, I've been able to successfully drop this in-place of the original without issue.
@oblador Any idea on whether you'll be looking to add this to Master? Not having completion promises on transition/transitionTo seems an oversight to me.
Thanks again for making the fix 馃憤
Hello @oblador, for those that would like promisified react-native-animatable transition/transitionTo, the choice is currently either
both of which are behind your master. Would it be possible to have those methods return promises? Or are they easily promisifiable in some other way? thanks
Most helpful comment
Hey guys, I started a project with react-native-animatable. It's a fantastic library. And this feature will be very welcome.
I'm not sure if this is the best way to make it, but I've been using it for some time now and have not experienced any problems. The feature counts the number of completed iterations and triggers the promise. It does not use 'setTimeout'.
I've created a fork at https://github.com/vramosx/react-native-animatable with this feature.
With this, we can use:
this.refs.objectRef.transitionTo({ opacity: 0 }).then(() => alert('Hey! Transition ends!'));or:
this.refs.objectRef.transition({opacity: 1}, { opacity: 0 }).then(() => alert('Hey! Transition ends!'));@oblador If it is a good solution and you want to add to the original, feel free to. I'm happy to help.