mirror of https://github.com/sveltejs/svelte
commit
00c41e2092
@ -0,0 +1,24 @@
|
||||
export default {
|
||||
test ( assert, component, target, window, raf ) {
|
||||
component.set({ visible: true });
|
||||
const div = target.querySelector( 'div' );
|
||||
assert.equal( div.foo, 0 );
|
||||
|
||||
raf.tick( 50 );
|
||||
assert.equal( div.foo, 0 );
|
||||
|
||||
raf.tick( 150 );
|
||||
assert.equal( div.foo, 1 );
|
||||
|
||||
component.set({ visible: false });
|
||||
assert.equal( div.bar, undefined );
|
||||
|
||||
raf.tick( 200 );
|
||||
assert.equal( div.bar, 1 );
|
||||
|
||||
raf.tick( 300 );
|
||||
assert.equal( div.bar, 0 );
|
||||
|
||||
component.destroy();
|
||||
}
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
{{#if visible}}
|
||||
<div in:foo out:bar>delayed</div>
|
||||
{{/if}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo: function ( node, params ) {
|
||||
return {
|
||||
delay: 50,
|
||||
duration: 100,
|
||||
tick: t => {
|
||||
node.foo = t;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
bar: function ( node, params ) {
|
||||
return {
|
||||
delay: 50,
|
||||
duration: 100,
|
||||
tick: t => {
|
||||
node.bar = t;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,29 @@
|
||||
export default {
|
||||
test ( assert, component, target, window, raf ) {
|
||||
component.set({ visible: true });
|
||||
const div = target.querySelector( 'div' );
|
||||
assert.equal( div.foo, 0 );
|
||||
|
||||
raf.tick( 50 );
|
||||
assert.equal( div.foo, 0 );
|
||||
|
||||
raf.tick( 100 );
|
||||
assert.equal( div.foo, 0.5 );
|
||||
|
||||
component.set({ visible: false });
|
||||
|
||||
raf.tick( 125 );
|
||||
assert.equal( div.foo, 0.75 );
|
||||
|
||||
raf.tick( 150 );
|
||||
assert.equal( div.foo, 1 );
|
||||
|
||||
raf.tick( 175 );
|
||||
assert.equal( div.foo, 0.75 );
|
||||
|
||||
raf.tick( 250 );
|
||||
assert.equal( div.foo, 0 );
|
||||
|
||||
component.destroy();
|
||||
}
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
{{#if visible}}
|
||||
<div transition:foo>delayed</div>
|
||||
{{/if}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo: function ( node, params ) {
|
||||
return {
|
||||
delay: 50,
|
||||
duration: 100,
|
||||
tick: t => {
|
||||
node.foo = t;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element cannot have both an 'in' directive and a 'transition' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"pos": 12
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div in:foo transition:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element can only have one 'in' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
},
|
||||
"pos": 12
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div in:foo in:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element cannot have both an 'out' directive and a 'transition' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"pos": 13
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div out:foo transition:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element can only have one 'out' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 13
|
||||
},
|
||||
"pos": 13
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div out:foo out:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element cannot have both a 'transition' directive and an 'in' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
},
|
||||
"pos": 20
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div transition:foo in:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element cannot have both a 'transition' directive and an 'out' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
},
|
||||
"pos": 20
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div transition:foo out:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "An element can only have one 'transition' directive",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
},
|
||||
"pos": 20
|
||||
}]
|
@ -0,0 +1,10 @@
|
||||
<div transition:foo transition:bar>...</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
transitions: {
|
||||
foo,
|
||||
bar
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "Missing transition 'foo'",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"pos": 5
|
||||
}]
|
@ -0,0 +1 @@
|
||||
<div in:foo>...</div>
|
Loading…
Reference in new issue