mirror of https://github.com/sveltejs/svelte
fix: make snippet effects transparent for transitions (#11195)
parent
8fef412dbb
commit
1c33ff0107
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: make snippet effects transparent for transitions
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
/** @type {{ children: import('svelte').Snippet }} */
|
||||
let { children } = $props();
|
||||
|
||||
let visible = $state(false);
|
||||
</script>
|
||||
|
||||
<button onclick={() => visible = !visible}>toggle</button>
|
||||
|
||||
{#if visible}
|
||||
{@render children()}
|
||||
{/if}
|
@ -0,0 +1,20 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { ok, test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target, raf }) {
|
||||
const button = target.querySelector('button');
|
||||
ok(button);
|
||||
|
||||
flushSync(() => button.click());
|
||||
raf.tick(50);
|
||||
assert.htmlEqual(target.innerHTML, '<button>toggle</button><p style="opacity: 0.5;">hello</p>');
|
||||
|
||||
flushSync(() => button.click());
|
||||
raf.tick(75);
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<button>toggle</button><p style="opacity: 0.25;">hello</p>'
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import { fade } from 'svelte/transition';
|
||||
import { linear } from 'svelte/easing';
|
||||
import Container from './Container.svelte';
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<p style="opacity: 1" transition:fade={{ duration: 100, easing: linear }}>hello</p>
|
||||
</Container>
|
Loading…
Reference in new issue