Skip to content

Transitions: dynamic attributes #3633

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
gotys opened this issue Sep 29, 2019 · 8 comments
Closed

Transitions: dynamic attributes #3633

gotys opened this issue Sep 29, 2019 · 8 comments
Labels
awaiting submitter needs a reproduction, or clarification stale-bot temp-stale
Milestone

Comments

@gotys
Copy link

gotys commented Sep 29, 2019

It seems the Outro transitions aren't respecting dynamic attributes.
I am trying to have a page-slider that dynamically updates the Out / In Fly directions based on some mathematical logic.
It seems that once the Element is mounted the transition settings cannot be updated.

I made a little demo here that should change the outro speed when buttons clicked, but does not:
https://svelte.dev/repl/f8a0a3d1010d4669a81940770547dabf?version=3.12.1

By the way - if there is currently a workaround, can someone please tell me ?

@remimi
Copy link

remimi commented Oct 6, 2019

I think the easiest way to do this is to use the in and out directives.

Like this :

<div in:fly="{{x: 500, duration: variableSpeed}}" out:fly="{{x: 500, duration: variableSpeed}}" style="{css}">
	My Speed is {variableSpeed}
</div>

Hope this helps !

@Conduitry
Copy link
Member

I don't see off the top of my head why this would have to work the way it does. If the (two-way) transition is currently underway, I can see why changes wouldn't take effect, because we need it to be reversible before completing. But I'm not sure why, once the transition-in is completely finished, those same params would need to be locked in for the later transition-out.

@Conduitry Conduitry added the awaiting submitter needs a reproduction, or clarification label Oct 20, 2019
@gotys
Copy link
Author

gotys commented Oct 20, 2019

I don't see off the top of my head why this would have to work the way it does. If the (two-way) transition is currently underway, I can see why changes wouldn't take effect, because we need it to be reversible before completing. But I'm not sure why, once the transition-in is completely finished, those same params would need to be locked in for the later transition-out.

My use case is page transitions in my application. Imagine an app with sapper routes, where each route can enter ( fly animation ) either from left or right, but will leave the view also either to the left, or to the right - depending on some internal logic. In other words, I don't know the direction of exit until some link is clicked - and then based on where I am heading next - THAN I decide the exit direction.

Hope it makes sense, thank you.

@thelowman
Copy link

I agree that you should be able to use a single transition attribute and change it as needed but specifying both in and out transitions separately does the trick. I've posted this REPL that I've worked out to help me solve a problem that I think may be similar to yours. I hope it helps.

@jcarpenter
Copy link

I hit this when trying to dynamically set animate:flip params. This REPL captures what I'm seeing.

Svelte encourages reactive dynamism everywhere, so this feels like a counter-intuitive limitation. Barring a fix, perhaps the docs could mention the issue? Might save others time trying to figure out what's going on.

@stale
Copy link

stale bot commented Jun 26, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Dec 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Dec 28, 2021
@Rich-Harris Rich-Harris added this to the 5.0 milestone Apr 2, 2024
@dummdidumm
Copy link
Member

Works in Svelte 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter needs a reproduction, or clarification stale-bot temp-stale
Projects
None yet
Development

No branches or pull requests

8 participants