-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Immediate tweened store value update with { duration: 0 } option #4399
Comments
I'd prefer to early-out and immediately set the value in this case as well. |
I bumped into this issue while implementing touch gestures for an image gallery. I wanted to set the value immediately when handling touch events, but have the possibility to tween/spring the values when, for example, the user's gesture moved something a bit too far and I need to revert state to the nearest sensible value. |
This has been implemented in 3.22.0. |
Thanks for the quick merge and release @Conduitry! |
Thanks ! |
Is your feature request related to a problem? Please describe.
In Firefox and Safari, when there's a tweened store and we call
tweenedStore.update(fn, {duration: 0})
sometimes the tweened value gets computed toNaN
. Then I went to read about how the value gets computed:https://github.com/sveltejs/svelte/blob/master/src/runtime/motion/tweened.ts#L121
As the result is based on
elapsed/duration
, which makes sense to not have duration to be 0 mathematically. Although, in FF and Safari theelapsed
variable can be0
when compute is getting executed, which causes the result of the compute to be NaN.Describe the solution you'd like
if the
options.duration
is 0 then we set the value right away instead of going through the interpolation compute ?Describe alternatives you've considered
options.duration
when <=0How important is this feature to you?
Currently I'm using
{duration: 1}
as a work around. when I want to update some tweened store "immediately". I'm curious about what would be a good way to handle this tho !Additional context
Thanks for reading !
The text was updated successfully, but these errors were encountered: