diff --git a/src/internal/transitions.js b/src/internal/transitions.js index 4b039402b2..98418556a0 100644 --- a/src/internal/transitions.js +++ b/src/internal/transitions.js @@ -89,8 +89,7 @@ export function wrapTransition(component, node, fn, params, intro) { }, start(program) { - // TODO find an alternative to this - // component.fire(`${program.b ? 'intro' : 'outro'}.start`, { node }); + node.dispatchEvent(new window.CustomEvent(`${program.b ? 'intro' : 'outro'}start`)); program.a = this.t; program.delta = program.b - program.a; @@ -129,8 +128,7 @@ export function wrapTransition(component, node, fn, params, intro) { if (obj.tick) obj.tick(this.t, 1 - this.t); - // TODO find an alternative to this - // component.fire(`${program.b ? 'intro' : 'outro'}.end`, { node }); + node.dispatchEvent(new window.CustomEvent(`${program.b ? 'intro' : 'outro'}end`)); if (!program.b && !program.invalidated) { program.group.callbacks.push(() => { diff --git a/test/runtime/samples/transition-js-events/_config.js b/test/runtime/samples/transition-js-events/_config.js index 33f924022e..7a25fcc0d6 100644 --- a/test/runtime/samples/transition-js-events/_config.js +++ b/test/runtime/samples/transition-js-events/_config.js @@ -4,22 +4,24 @@ export default { things: ['a', 'b', 'c', 'd'] }, + intro: true, + test (assert, component, target, window, raf) { raf.tick(50); assert.deepEqual(component.intros.sort(), ['a', 'b', 'c', 'd']); - assert.equal(component.introCount, 4); + assert.equal(component.intro_count, 4); raf.tick(100); - assert.equal(component.introCount, 0); + assert.equal(component.intro_count, 0); component.visible = false; raf.tick(150); assert.deepEqual(component.outros.sort(), ['a', 'b', 'c', 'd']); - assert.equal(component.outroCount, 4); + assert.equal(component.outro_count, 4); raf.tick(200); - assert.equal(component.outroCount, 0); + assert.equal(component.outro_count, 0); component.visible = true; component.$on('intro.start', () => { @@ -28,6 +30,6 @@ export default { raf.tick(250); assert.deepEqual(component.intros.sort(), ['a', 'a', 'b', 'b', 'c', 'c', 'd', 'd']); - assert.equal(component.introCount, 4); + assert.equal(component.intro_count, 4); } }; \ No newline at end of file diff --git a/test/runtime/samples/transition-js-events/main.html b/test/runtime/samples/transition-js-events/main.html index c3f2fc90ed..909cfe981b 100644 --- a/test/runtime/samples/transition-js-events/main.html +++ b/test/runtime/samples/transition-js-events/main.html @@ -1,16 +1,14 @@ - - {#each things as thing} {#if visible} -
{thing}
+{thing}
{/if} {/each} \ No newline at end of file