mirror of https://github.com/sveltejs/svelte
[fix] create in transition even if intro is initialized (#6516)
parent
0d9dd15392
commit
c8732c8a27
@ -0,0 +1,21 @@
|
|||||||
|
export default {
|
||||||
|
test({ assert, component, target, window, raf }) {
|
||||||
|
component.visible = true;
|
||||||
|
const div = target.querySelector('div');
|
||||||
|
|
||||||
|
// animation duration of `in` should be 10ms.
|
||||||
|
assert.equal(div.style.animation, '__svelte_1670736059_0 10ms linear 0ms 1 both');
|
||||||
|
|
||||||
|
// animation duration of `out` should be 5ms.
|
||||||
|
component.visible = false;
|
||||||
|
assert.equal(div.style.animation, '__svelte_1670736059_0 10ms linear 0ms 1 both, __svelte_1998461463_0 5ms linear 0ms 1 both');
|
||||||
|
|
||||||
|
// change param
|
||||||
|
raf.tick(1);
|
||||||
|
component.param = true;
|
||||||
|
component.visible = true;
|
||||||
|
|
||||||
|
// animation duration of `in` should be 20ms.
|
||||||
|
assert.equal(div.style.animation, '__svelte_722598827_0 20ms linear 0ms 1 both');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,26 @@
|
|||||||
|
<script>
|
||||||
|
export let visible = false;
|
||||||
|
export let param = false;
|
||||||
|
|
||||||
|
function getInParam() {
|
||||||
|
return {
|
||||||
|
duration: param ? 20 : 10,
|
||||||
|
css: t => {
|
||||||
|
return `opacity: ${t}`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOutParam() {
|
||||||
|
return {
|
||||||
|
duration: param ? 15 : 5,
|
||||||
|
css: t => {
|
||||||
|
return `opacity: ${t}`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if visible}
|
||||||
|
<div in:getInParam out:getOutParam></div>
|
||||||
|
{/if}
|
Loading…
Reference in new issue