diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts index 8883587929..e08c77dac4 100644 --- a/src/compile/render-dom/wrappers/Element/index.ts +++ b/src/compile/render-dom/wrappers/Element/index.ts @@ -595,13 +595,13 @@ export default class ElementWrapper extends Wrapper { if (${name}) ${name}.invalidate(); @add_render_callback(() => { - if (!${name}) ${name} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true); + if (!${name}) ${name} = @create_transition(${this.var}, ${fn}, ${snippet}, true); ${name}.run(1); }); `); block.builders.outro.addBlock(deindent` - if (!${name}) ${name} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, false); + if (!${name}) ${name} = @create_transition(${this.var}, ${fn}, ${snippet}, false); ${name}.run(0, () => { #outrocallback(); ${name} = null; @@ -630,7 +630,7 @@ export default class ElementWrapper extends Wrapper { block.builders.intro.addConditional(`@intros.enabled`, deindent` @add_render_callback(() => { - ${introName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true); + ${introName} = @create_transition(${this.var}, ${fn}, ${snippet}, true); ${introName}.run(1); }); `); @@ -651,7 +651,7 @@ export default class ElementWrapper extends Wrapper { // TODO hide elements that have outro'd (unless they belong to a still-outroing // group) prior to their removal from the DOM block.builders.outro.addBlock(deindent` - ${outroName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, false); + ${outroName} = @create_transition(${this.var}, ${fn}, ${snippet}, false); ${outroName}.run(0, #outrocallback); `); diff --git a/src/internal/transitions.js b/src/internal/transitions.js index ad3b4d5f70..5aaed5b859 100644 --- a/src/internal/transitions.js +++ b/src/internal/transitions.js @@ -24,13 +24,13 @@ export function group_outros() { }; } -export function wrapTransition(component, node, fn, params, intro) { - let config = fn.call(component, node, params); +export function create_transition(node, fn, params, intro) { + let config = fn(node, params); let duration; let ease; let cssText; - let initialised = false; + let ready = false; let t = intro ? 0 : 1; let running = false; @@ -106,14 +106,14 @@ export function wrapTransition(component, node, fn, params, intro) { callback: callback || noop }; - if (intro && !initialised) { + if (intro && !ready) { if (config.css && config.delay) { cssText = node.style.cssText; node.style.cssText += config.css(0, 1); } if (config.tick) config.tick(0, 1); - initialised = true; + ready = true; } if (!b) {