mirror of https://github.com/sveltejs/svelte
parent
26ed67267c
commit
dfe00d8627
@ -0,0 +1,47 @@
|
||||
export default {
|
||||
data: {
|
||||
name: 'world'
|
||||
},
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
global.count = 0;
|
||||
let now = 0;
|
||||
let callback;
|
||||
|
||||
window.performance = { now: () => now };
|
||||
global.requestAnimationFrame = cb => callback = cb;
|
||||
|
||||
component.set({ visible: true });
|
||||
assert.equal( global.count, 1 );
|
||||
const div = target.querySelector( 'div' );
|
||||
assert.equal( div.foo, 0 );
|
||||
|
||||
now = 300;
|
||||
callback();
|
||||
component.set({ name: 'everybody' });
|
||||
assert.equal( div.foo, 0.75 );
|
||||
assert.htmlEqual( div.innerHTML, 'hello everybody!' );
|
||||
|
||||
component.set({ visible: false, name: 'again' });
|
||||
assert.htmlEqual( div.innerHTML, 'hello everybody!' );
|
||||
|
||||
now = 500;
|
||||
callback();
|
||||
assert.equal( div.foo, 0.25 );
|
||||
|
||||
component.set({ visible: true });
|
||||
now = 700;
|
||||
callback();
|
||||
assert.equal( div.foo, 0.75 );
|
||||
assert.htmlEqual( div.innerHTML, 'hello again!' );
|
||||
|
||||
now = 800;
|
||||
callback();
|
||||
assert.equal( div.foo, 1 );
|
||||
|
||||
now = 900;
|
||||
callback();
|
||||
|
||||
component.destroy();
|
||||
}
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
{{#if visible}}
|
||||
<div transition:foo>hello {{name}}!</div>
|
||||
{{/if}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo: function ( node, params ) {
|
||||
global.count += 1;
|
||||
return {
|
||||
duration: 400,
|
||||
tick: t => {
|
||||
node.foo = t;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue