mirror of https://github.com/sveltejs/svelte
parent
31b57f2b6e
commit
486a9baea5
@ -0,0 +1 @@
|
|||||||
|
A
|
@ -0,0 +1,10 @@
|
|||||||
|
export default {
|
||||||
|
async test({ assert, target, window, raf }) {
|
||||||
|
const button = target.querySelector("button");
|
||||||
|
const event = new window.MouseEvent("click");
|
||||||
|
assert.htmlEqual(target.innerHTML, "A");
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
raf.tick(500);
|
||||||
|
assert.htmlEqual(target.innerHTML, "A");
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,36 @@
|
|||||||
|
<script>
|
||||||
|
import Component from "./Component.svelte";
|
||||||
|
function foo(node, params) {
|
||||||
|
return {
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let isFirst = true;
|
||||||
|
let animationActive = false;
|
||||||
|
|
||||||
|
const toggle = () => {
|
||||||
|
if (animationActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
animationActive = true;
|
||||||
|
Promise.resolve().then(() => {
|
||||||
|
isFirst = !isFirst;
|
||||||
|
animationActive = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={toggle}>TOGGLE</button>
|
||||||
|
{#if !animationActive}
|
||||||
|
<div out:foo>
|
||||||
|
{#if isFirst}
|
||||||
|
<Component {isFirst} />
|
||||||
|
{:else}
|
||||||
|
<Component {isFirst} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
Loading…
Reference in new issue