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
// within <script /> of a .svelte file!
...
letsomeSpring=spring(0)letsomeStore=derived(...)$: $someSpring=$someStore
...
Now, whenever I change $someStore, $someSpring gradually changes the value as it should and you can use it for butter smooth animations in the markup below.
How can I get those three lines in a separate .ts module which I can import in any .svelte-file but still nicely working? I tried something with derived (see below) but didn't get it working and had hard transitions, only.
PS:
someStore is required to be a store for my use case, my example is simplified
what I've tried:
// in a .ts fileexportconstextSpring=()=>{letsomeSpring=spring(0)letsomeStore=derived(...)returnderived([someStore],([$someStore])=>{someSpring.set($someStore)returnsomeSpring})}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Now, whenever I change
$someStore
,$someSpring
gradually changes the value as it should and you can use it for butter smooth animations in the markup below.How can I get those three lines in a separate
.ts
module which I can import in any.svelte
-file but still nicely working? I tried something withderived
(see below) but didn't get it working and had hard transitions, only.PS:
someStore
is required to be a store for my use case, my example is simplifiedBeta Was this translation helpful? Give feedback.
All reactions