-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
animate directive with duration:0 should be completely disabled / Programmatically disable animate directive #7889
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
Comments
Here's one way to disable the flip animation: REPL Essentially, you toggle between the imported <script>
import { flip } from 'svelte/animate';
let items = [`item ${0}`];
let idx = 1;
let shouldFlip = true;
function removeItem(idx) {
items.splice(idx, 1);
items = items;
}
$: flipFn = shouldFlip ? flip : () => ({ css: () => ''});
</script>
<label><input type="checkbox" bind:checked={shouldFlip}> Use flip?</label>
<button on:click={() => items = [...items, `item ${idx++}`]}>
Add item
</button>
{#each items as item, idx (item)}
<p animate:flipFn>
{item}
<button on:click={() => removeItem(idx)}>
Remove
</button>
</p>
{/each} |
Thanks for your answer, but unfortunately, it didn't work in my case. |
Can you provide a REPL or minimal reproduction reproducing the issue? |
Here you have: REPL The lags/jumps are more noticeable in Safari than in Chrome and when scrolling from bottom to top. |
Closing in favor of #6942 - it would solve this by supporting switching out the directive with a falsy value so that it is disabled. Also this might have been fixed with Svelte 5 |
Describe the problem
When using animate directive I want to be able to programmatically disable it.
Using duration:0 or even swapping the animate function with an empty one does not completely disable it:
You can see in the video that, when using these strategies, there is still something going on that produces a jump when scrolling.
svelte.animate.mov
Describe the proposed solution
Completely disable animate directive when there is no animation to play.
Alternatives considered
Allow animate:null or animate:undefined
Importance
nice to have
The text was updated successfully, but these errors were encountered: