NativeScript
NativeScript copied to clipboard
Ability to stop an animation, or cancel and not reset view property values
I am frequently coming across a regular requirement to be able to stop an animation mid way through its animating period, and specifically ensuring that the animated view(s) properties remain in their last updated state by the animation engine.
Is the a reason why a .stop() method hasn't been provided, and are there any plans to support this?
Using the .cancel() method on an Animation will indeed stop the animation, but has the symptom of returning the animated view properties back to their original position so this is not an option.
Perhaps another solution would be the ability to pass in a boolean to the cancel method such as cancel(true) to indicate the intention not to "reset" the properties, but instead leave them as is, as when the animation was cancelled.
Any feedback on this would be greatly appreciated.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I found this interesting thread on SO: http://stackoverflow.com/a/841967/1495716
At least for iOS, it seems like what would need to be implemented is a very short second animation that uses: UIViewAnimationOptionBeginFromCurrentState
https://developer.apple.com/reference/uikit/uiviewanimationoptions/uiviewanimationoptionbeginfromcurrentstate
Look forward to some feedback on this.
@timricker
Indeed the cancel method will reset all values. At this very moment, there is no out of the box way to pause an animation (or save the state of the properties at the moment of cancelation)
@valentinstoychev @enchev - If I was to add the ability to pause/cancel (w/o reset) would this patch be accepted into core?
Hey @NathanaelA,
As you know we treat every pull request independently - your pull requests are usually merged! :)
@enchev - Yes, I realize that; but I really don't want to waste a lot of time if this isn't functionality that the team wants built into NS. I might also add the question is the Animation system changing much/any for 3.0...
@NathanaelA go for it. Uncertainty is the only certainty there is :)
What's the update on this? I would very much like to use this feature.
Are there any workarounds in Android? Or perhaps the feature was implemented? Couldn't find it if so