-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly delay intro transitions
WAAPI applies the styles of a delayed animation only when that animation starts. In the case of fade-in transitions that means the element is visible, then goes invisible and fades in. Fix that by never applying a delay on intro transitions, instead add keyframes of the initial state for the duration of the delay. Fixes #10876
- Loading branch information
1 parent
9c1371a
commit c170e27
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: properly delay intro transitions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/svelte/tests/runtime-runes/samples/transition-delayed/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { flushSync } from '../../../../src/index-client.js'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, raf, target }) { | ||
const btn = target.querySelector('button'); | ||
|
||
// in | ||
btn?.click(); | ||
flushSync(); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<button>toggle</button><p style="opacity: 0;">delayed fade</p>' | ||
); | ||
raf.tick(1); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<button>toggle</button><p style="opacity: 0;">delayed fade</p>' | ||
); | ||
|
||
raf.tick(99); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<button>toggle</button><p style="opacity: 0;">delayed fade</p>' | ||
); | ||
|
||
raf.tick(150); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<button>toggle</button><p style="opacity: 0.5;">delayed fade</p>' | ||
); | ||
|
||
raf.tick(201); | ||
assert.htmlEqual(target.innerHTML, '<button>toggle</button><p style="">delayed fade</p>'); | ||
|
||
// out | ||
btn?.click(); | ||
flushSync(); | ||
raf.tick(75); | ||
assert.htmlEqual(target.innerHTML, '<button>toggle</button><p style="">delayed fade</p>'); | ||
|
||
raf.tick(150); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<button>toggle</button><p style="opacity: 0.5;">delayed fade</p>' | ||
); | ||
} | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/svelte/tests/runtime-runes/samples/transition-delayed/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script> | ||
import { fade } from 'svelte/transition'; | ||
let visible = $state(false); | ||
</script> | ||
|
||
<button onclick={() => (visible = !visible)}>toggle</button> | ||
|
||
{#if visible} | ||
<p transition:fade={{ delay: 100, duration: 100 }}>delayed fade</p> | ||
{/if} |