mirror of https://github.com/sveltejs/svelte
Closes #3918 and supersedes #4019 (extremely similar change, mostly just adds tests/docs)pull/8068/head
parent
91f8764145
commit
3d37735136
@ -0,0 +1,19 @@
|
||||
export default {
|
||||
test({ assert, component, target, raf }) {
|
||||
component.visible = true;
|
||||
|
||||
const divIn = target.querySelector('#in');
|
||||
const divOut = target.querySelector('#out');
|
||||
const divBoth = target.querySelector('#both');
|
||||
|
||||
assert.equal(divIn.initial, 'in');
|
||||
assert.equal(divOut.initial, 'out');
|
||||
assert.equal(divBoth.initial, 'both');
|
||||
|
||||
return Promise.resolve().then(() => {
|
||||
assert.equal(divIn.later, 'in');
|
||||
assert.equal(divOut.later, 'out');
|
||||
assert.equal(divBoth.later, 'both');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
export let visible;
|
||||
|
||||
function foo(node, params, options) {
|
||||
node.initial = options.direction
|
||||
|
||||
return (opts) => {
|
||||
node.later = opts.direction;
|
||||
|
||||
return {
|
||||
duration: 10,
|
||||
};
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div id="both" transition:foo></div>
|
||||
<div id="in" in:foo></div>
|
||||
{/if}
|
||||
|
||||
{#if !visible}
|
||||
<div id="out" out:foo></div>
|
||||
{/if}
|
||||
@ -0,0 +1,13 @@
|
||||
export default {
|
||||
test({ assert, component, target }) {
|
||||
component.visible = true;
|
||||
|
||||
const divIn = target.querySelector('#in');
|
||||
const divOut = target.querySelector('#out');
|
||||
const divBoth = target.querySelector('#both');
|
||||
|
||||
assert.equal(divIn.direction, 'in');
|
||||
assert.equal(divOut.direction, 'out');
|
||||
assert.equal(divBoth.direction, 'both');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
export let visible = false;
|
||||
|
||||
function foo(node, params, options) {
|
||||
console.log("options", options);
|
||||
node.direction = options.direction
|
||||
|
||||
return {
|
||||
duration: 10,
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div id="both" transition:foo></div>
|
||||
<div id="in" in:foo></div>
|
||||
{/if}
|
||||
|
||||
{#if !visible}
|
||||
<div id="out" out:foo></div>
|
||||
{/if}
|
||||
Loading…
Reference in new issue