svelte icon indicating copy to clipboard operation
svelte copied to clipboard

fix: improve transition outro effect

Open trueadm opened this issue 1 year ago • 3 comments

Fixes https://github.com/sveltejs/svelte/issues/10219.

trueadm avatar Jan 18 '24 14:01 trueadm

🦋 Changeset detected

Latest commit: df91fd5edfee7232a093c2f5b4d2c7e43ca465f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jan 18 '24 14:01 changeset-bot[bot]

Thank you @trueadm, ALMOST perfect. The easing indeed seems to have been fixed, however, a new issue is that the outro transition now goes beyond the initial position of the element — in this video, notice how the the first time the checkbox is toggled, the outro transition ends with the element having a little bit of space on the left, whereas the second time, it goes too far to the left (repro):

https://github.com/sveltejs/svelte/assets/26527405/2d1aa2d4-080e-4088-8ad6-6474a9c63163

aradalvand avatar Jan 19 '24 07:01 aradalvand

Update: I'm still not happy with this (I pushed some fixes but they're not right still). It turns out that this is far more complicated to get right. Here is the working example I've been using locally to test this with:

<script>
	import { fly } from 'svelte/transition';
	import { cubicOut } from 'svelte/easing';

	let show = false;
</script>

<label for="show">show:</label><input type="checkbox" id="show" bind:checked={show} />
{#if show}
	<h1 transition:fly={{ duration: 2000, easing: cubicOut, x: -200, opacity: 0.5 }}>Hello World!</h1>
{/if}


<h1>Hello World!</h1>
<h1 style="transform: translateX(-200px)">Hello World!</h1>

<style>
	h1 {
		margin: auto;
		width: fit-content;
	}
</style>

@Rich-Harris I wonder if you have some bandwidth if you could play around with this and see if you can discover anything? Specifically if you play around with the logic in packages/svelte/src/internal/client/transitions.js that are the changed lines in this PR, you might come across something.

trueadm avatar Feb 09 '24 18:02 trueadm

@trueadm what was the conclusion here? i'd have loved to see this fixed.

xamir82 avatar Mar 22 '24 22:03 xamir82

@xamir82 This is fixed now :)

trueadm avatar Mar 22 '24 22:03 trueadm

@trueadm Ah yes :) It seems like it is. Thank you! Missed which PR actually fixed it though! I guess https://github.com/sveltejs/svelte/issues/10219 could also be closed as completed now?

xamir82 avatar Mar 23 '24 03:03 xamir82