mirror of https://github.com/sveltejs/svelte
[feat] Add options w/ direction to transitions (#8068)
parent
14f33cfe61
commit
84d61c61f8
@ -0,0 +1,19 @@
|
||||
export default {
|
||||
test({ assert, component, target }) {
|
||||
component.visible = true;
|
||||
|
||||
const div_in = target.querySelector('#in');
|
||||
const div_out = target.querySelector('#out');
|
||||
const div_both = target.querySelector('#both');
|
||||
|
||||
assert.equal(div_in.initial, 'in');
|
||||
assert.equal(div_out.initial, 'out');
|
||||
assert.equal(div_both.initial, 'both');
|
||||
|
||||
return Promise.resolve().then(() => {
|
||||
assert.equal(div_in.later, 'in');
|
||||
assert.equal(div_out.later, 'out');
|
||||
assert.equal(div_both.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 div_in = target.querySelector('#in');
|
||||
const div_out = target.querySelector('#out');
|
||||
const div_both = target.querySelector('#both');
|
||||
|
||||
assert.equal(div_in.direction, 'in');
|
||||
assert.equal(div_out.direction, 'out');
|
||||
assert.equal(div_both.direction, 'both');
|
||||
}
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
export let visible = false;
|
||||
|
||||
function foo(node, _params, 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