This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
[Feature] Expose animation data (in particular, spring velocity) #217
Labels
Feature
Feature request
Is your feature request related to a problem? Please describe.
Currently there's no way to really manipulate a spring animation, all of it is handled "magically" by Motion One. This can be a problem if you wanted to affect the animation dynamically, for example by giving it a new impulse.
Of course you could just use
animate
again on the same element and trust that MO will persist the current values, but as far as I can tell that doesn't happen if you've passed a function to the first animation.If you could at least read the current velocity of a previous spring animation, you could pass that value as the initial velocity of new anim.
Overall, even though my current use case is only related to springs, I feel that having access to all animation data in an object could be useful, in particular if that object is passed as along with / instead of
progress
to function animations.Describe the solution you'd like
Instead of
animation.duration
,animation.playState
, etc:finished
and writable props (currentTime
,playbackRate
) at the top level;For function animations, the syntax would change like:
Note that I'm calling the value
output
and notprogress
, imo the "progress" of an animation always linearly advances from 0 to 1 (ie the "output" of an animation with the default ease atprogress == 0.5
would be ~0.7835
. (And "progress" is different than "time" because the latter includes repeats.)If all that's needed is the output, that can be easily achieved via destructuring:
Describe alternatives you've considered
Another way to be able to more easily manipulate function animation would be to add an identifier parameter, to tell MO to persist values from a previous animation created with the same identifier. I don't think that's as flexible though, and the data object could also be useful in other contexts.
Additional context
I just wanna say I've just started using Motion One and I might be missing something for this particular issue, but either way it's a really great library and very comfortable to use, I thought it was worth mentioning!
The text was updated successfully, but these errors were encountered: