Skip to content

Commit

Permalink
dont transform bidi transitions twice - fixes #962
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 3, 2017
1 parent 832311a commit 3350f16
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/generators/dom/visitors/Element/addTransitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export default function addTransitions(

if (!intro && !outro) return;

if (intro) block.contextualise(intro.expression); // TODO remove all these
if (outro) block.contextualise(outro.expression);

if (intro === outro) {
block.contextualise(intro.expression); // TODO remove all these

const name = block.getUniqueName(`${node.var}_transition`);
const snippet = intro.expression
? intro.metadata.snippet
Expand Down Expand Up @@ -49,6 +48,8 @@ export default function addTransitions(
const outroName = outro && block.getUniqueName(`${node.var}_outro`);

if (intro) {
block.contextualise(intro.expression);

block.addVariable(introName);
const snippet = intro.expression
? intro.metadata.snippet
Expand All @@ -74,6 +75,8 @@ export default function addTransitions(
}

if (outro) {
block.contextualise(outro.expression);

block.addVariable(outroName);
const snippet = outro.expression
? outro.metadata.snippet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
data: {
duration: 200
},

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, 100);

raf.tick(100);
assert.equal(div.foo, 200);

raf.tick(101);

component.destroy();
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{#if visible}}
<div transition:foo='{k: duration}'>fades in</div>
{{/if}}

<script>
export default {
transitions: {
foo(node, params) {
return {
duration: 100,
tick: t => {
node.foo = t * params.k;
}
};
}
}
};
</script>

0 comments on commit 3350f16

Please sign in to comment.