mirror of https://github.com/sveltejs/svelte
abort intros before restarting them - fixes #546
parent
c712ad502a
commit
58504a36ff
@ -0,0 +1,45 @@
|
|||||||
|
export default {
|
||||||
|
solo: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
visible: false,
|
||||||
|
things: [ 'a', 'b', 'c' ]
|
||||||
|
},
|
||||||
|
|
||||||
|
test ( assert, component, target, window, raf ) {
|
||||||
|
component.set({ visible: true });
|
||||||
|
const divs = target.querySelectorAll( 'div' );
|
||||||
|
assert.equal( divs[0].foo, 0 );
|
||||||
|
assert.equal( divs[1].foo, 0 );
|
||||||
|
assert.equal( divs[2].foo, 0 );
|
||||||
|
|
||||||
|
raf.tick( 50 );
|
||||||
|
assert.equal( divs[0].foo, 0.5 );
|
||||||
|
assert.equal( divs[1].foo, 0.5 );
|
||||||
|
assert.equal( divs[2].foo, 0.5 );
|
||||||
|
|
||||||
|
component.set({ visible: false });
|
||||||
|
|
||||||
|
raf.tick( 70 );
|
||||||
|
assert.equal( divs[0].foo, 0.7 );
|
||||||
|
assert.equal( divs[1].foo, 0.7 );
|
||||||
|
assert.equal( divs[2].foo, 0.7 );
|
||||||
|
|
||||||
|
assert.equal( divs[0].bar, 0.8 );
|
||||||
|
assert.equal( divs[1].bar, 0.8 );
|
||||||
|
assert.equal( divs[2].bar, 0.8 );
|
||||||
|
|
||||||
|
component.set({ visible: true });
|
||||||
|
|
||||||
|
raf.tick( 100 );
|
||||||
|
assert.equal( divs[0].foo, 0.3 );
|
||||||
|
assert.equal( divs[1].foo, 0.3 );
|
||||||
|
assert.equal( divs[2].foo, 0.3 );
|
||||||
|
|
||||||
|
assert.equal( divs[0].bar, 1 );
|
||||||
|
assert.equal( divs[1].bar, 1 );
|
||||||
|
assert.equal( divs[2].bar, 1 );
|
||||||
|
|
||||||
|
component.destroy();
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
{{#each things as thing}}
|
||||||
|
{{#if visible}}
|
||||||
|
<div in:foo out:bar>{{thing}}</div>
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
transitions: {
|
||||||
|
foo: function ( node, params ) {
|
||||||
|
return {
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.foo = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
bar: function ( node, params ) {
|
||||||
|
return {
|
||||||
|
duration: 100,
|
||||||
|
tick: t => {
|
||||||
|
node.bar = t;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in new issue