forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add options w/ direction to transitions
Closes sveltejs#3918 and supersedes sveltejs#4019 (extremely similar change, mostly just adds tests/docs)
- Loading branch information
Showing
6 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/transition-js-deferred-option-direction/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
} | ||
}; |
24 changes: 24 additions & 0 deletions
24
test/runtime/samples/transition-js-deferred-option-direction/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
13 changes: 13 additions & 0 deletions
13
test/runtime/samples/transition-js-option-direction/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
test/runtime/samples/transition-js-option-direction/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |