Skip to content

Transitions for reactive data changes #5119

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

Closed
etienneburdet opened this issue Jul 9, 2020 · 3 comments
Closed

Transitions for reactive data changes #5119

etienneburdet opened this issue Jul 9, 2020 · 3 comments

Comments

@etienneburdet
Copy link

I often want my element to transition when the data inside changes. For exemple : 

<script>
    import { fade } from 'svelte/transition'
    let count = 0;
    const handleClick = () => count +=1
</script>

<button on:click={handleClick} transition:slide>
    Click me
</button>
<p> You cliked <strong transition:fade>{count}</strong> times</p>

It would be nice if the count could transition each time. But since the node is not remodev/added, no transition is triggered (I guess).

An answer on stack overflow suggested to add a fake {#each} block, but it sounds a bit bloated and unnatural. The alternative would be to trigger animations from the JS function, e.g. by adding classes. It seems waaaaay more complicated than transitionning with conditionals, while doing functionnally something pretty similar to transitions (unless I am missing something obvious…).

So it would be awesome if transition was working on reactive data change as well. It cannot be the syntax I describe (else what happens when we actually kill the node?), but something similar, like {count | transition:fade} would be great.

Right now I need it for a calendar (slide weeks in/out of the screen), but there many use cases I can think of (counters, corrected data etc.).

@Conduitry
Copy link
Member

This sounds like a duplicate of #1469.

@etienneburdet
Copy link
Author

Most likely yes (I searched only issues with "transition…). Having the ability to force recreate the node would solve most (all?) cases for transitions. I am not skilled enough to be sure though 😛 .

@antony
Copy link
Member

antony commented Jul 10, 2020

Closing as duplicate of #1469

@antony antony closed this as completed Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants