You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, with svelte/motion still in pre-runes land, if you want that derived value to change smoothly over time, you end up having to do lots of this:
...which is fine, but obviously not ideal. And I'd really love to be able to use runes consistently.
Describe the proposed solution
It'd be great to have a new version of svelte/motion's springs that work exactly like the derived rune when relevant:
letvalue=$state('a');letspring1=$spring(0);// no dependency, set spring1 directlyletspring2=$spring(value=='a' ? 0 : 1);// derived spring, changes to value make spring2 go smoothly between 0 and 1letspring3=$spring(()=>{letr=0;for(constcofvalue){r+=c.codePointAt(0);}returnr;});// akin to derived.by, changes to value make spring3 go smoothly between 0 and... something
Importance
would make my life easier
The text was updated successfully, but these errors were encountered:
Adding new runes for this would be overkill, it also would interfere with autocompletion of more important runes like $state which disqualifies it immediately.
You can easily write your own function that wraps the $effect, e.g.
// export from a .svelte.js file if needed in many locationsexportfunctionderivedSpring(initial,valueFunction){conststore=spring(initial);$effect.pre(()=>{store.set(valueFunction());});returnstore;}
Describe the problem
With runes, making one value change depending on another one is super simple with
$derived
:However, with
svelte/motion
still in pre-runes land, if you want that derived value to change smoothly over time, you end up having to do lots of this:...which is fine, but obviously not ideal. And I'd really love to be able to use runes consistently.
Describe the proposed solution
It'd be great to have a new version of
svelte/motion
's springs that work exactly like the derived rune when relevant:Importance
would make my life easier
The text was updated successfully, but these errors were encountered: