-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Momentum #72
Comments
Yes. Allowing stateful things like momentum to be handled at the level of the Motions but not the Transitions is one of the big wins with our architecture. A motion doesn't necessarily need to choose to implement momentum the way I've done it in Move, but that's one pretty good way. In general, you get access to any prior motions, and you can decide what state to propagate from them. In the case of Move, we are adding the prior tween into our new tween, and adjusting our new tween so that by the time it finishes it will cancel out the remaining motion from the old tween. |
Gotcha. Makes sense. Trying to implement my own momentumless, cancellable Move motion, to be used with something like a collapsible panel. I think you don't want momentum in this case, as it feels a bit unnatural. I'm going for something like what you see in Materialize's collapse. I looked at the packaged Is there a more general concept/utility/property that exposes a tween's percentage completed, that custom Motions can use to properly account for cancelled animations? I poked around Tween and Curve and found some properties like (Am I thinking about this right? Is there a reason proportionateDuration should basically always be derived from |
I worked something together: if (this.prior) {
let { initialValue, finalValue, currentValue } = this.prior.xTween;
let percentageComplete = currentValue / Math.abs(finalValue - initialValue);
duration = percentageComplete * duration;
} Seems to work - but now I need to figure out how to share this with |
Keep in mind that you can put whatever properties you want on your own Motion, and then access them when one of your Motion instances is interrupting another. I also think it would be OK to expose spaceProgress and timeProgress as public API. This: let { initialValue, finalValue, currentValue } = this.prior.xTween;
let percentageComplete = currentValue / Math.abs(finalValue - initialValue); is only approximately true, although that is probably good enough for your purpose. |
Momentum seems to be a default property of most/all of the provided Motions, but I'm having trouble tracking down where it "lives".
Is it a part of the motions themselves, the code that is performing calculations on
prior
tweens?fade
seems like it does not have any sort of momentum. I'm basically trying to recreate this behavior formove
– a momentumless move, similar to what you'd have if you added a CSStransition
to an element – but I'm having trouble.I can post some code examples but figured I'd start with this in case I'm missing an obvious place to look.
The text was updated successfully, but these errors were encountered: