From 256fd84fcb72681cd0d1afa1b9b0290fdc29403a Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 17 Mar 2019 16:14:41 -0400 Subject: [PATCH 1/4] allow transition functions to return nothing --- src/internal/transitions.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/internal/transitions.js b/src/internal/transitions.js index a6579b0cef90..8af0d37f894b 100644 --- a/src/internal/transitions.js +++ b/src/internal/transitions.js @@ -40,6 +40,8 @@ export function on_outro(callback) { outros.callbacks.push(callback); } +const null_transition = { duration: 0 }; + export function create_in_transition(node, fn, params) { let config = fn(node, params); let running = false; @@ -58,7 +60,7 @@ export function create_in_transition(node, fn, params) { easing = linear, tick = noop, css - } = config; + } = config || null_transition; if (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++); tick(0, 1); @@ -132,7 +134,7 @@ export function create_out_transition(node, fn, params) { easing = linear, tick = noop, css - } = config; + } = config || null_transition; if (css) animation_name = create_rule(node, 1, 0, duration, delay, easing, css); @@ -221,7 +223,7 @@ export function create_bidirectional_transition(node, fn, params, intro) { easing = linear, tick = noop, css - } = config; + } = config || null_transition; const program = { start: window.performance.now() + delay, From 4a2bb526aed37a87566a6e652968ce5e96ef9dea Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 4 Aug 2019 12:34:26 -0400 Subject: [PATCH 2/4] oops --- src/runtime/internal/transitions.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 8e001c0aeb3c..951a6abbbf4d 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -65,15 +65,11 @@ export function transition_out(block, local: 0 | 1, detach: 0 | 1, callback) { } } -<<<<<<< HEAD:src/internal/transitions.js const null_transition = { duration: 0 }; -export function create_in_transition(node, fn, params) { -======= type TransitionFn = (node: Element, params: any) => TransitionConfig; export function create_in_transition(node: Element & ElementCSSInlineStyle, fn: TransitionFn, params: any) { ->>>>>>> master:src/runtime/internal/transitions.ts let config = fn(node, params); let running = false; let animation_name; From 60467f674c855b6c3b9c7e122256e7077724e7ef Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 4 Aug 2019 17:50:49 -0400 Subject: [PATCH 3/4] appease typescript --- src/runtime/internal/transitions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 951a6abbbf4d..9df4dd29b91f 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -87,7 +87,7 @@ export function create_in_transition(node: Element & ElementCSSInlineStyle, fn: easing = linear, tick = noop, css - } = config || null_transition; + } = config || (null_transition as TransitionConfig); if (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++); tick(0, 1); @@ -166,7 +166,7 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn: easing = linear, tick = noop, css - } = config || null_transition; + } = config || (null_transition as TransitionConfig); if (css) animation_name = create_rule(node, 1, 0, duration, delay, easing, css); @@ -260,7 +260,7 @@ export function create_bidirectional_transition(node: Element & ElementCSSInline easing = linear, tick = noop, css - } = config || null_transition; + } = config || (null_transition as TransitionConfig); const program = { start: now() + delay, From c069aba49a0e9d9ee23012e121c785b5d572b123 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 4 Aug 2019 18:24:24 -0400 Subject: [PATCH 4/4] tidy types --- src/runtime/internal/transitions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 9df4dd29b91f..ed23d3c1dd1e 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -65,7 +65,7 @@ export function transition_out(block, local: 0 | 1, detach: 0 | 1, callback) { } } -const null_transition = { duration: 0 }; +const null_transition: TransitionConfig = { duration: 0 }; type TransitionFn = (node: Element, params: any) => TransitionConfig; @@ -87,7 +87,7 @@ export function create_in_transition(node: Element & ElementCSSInlineStyle, fn: easing = linear, tick = noop, css - } = config || (null_transition as TransitionConfig); + } = config || null_transition; if (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++); tick(0, 1); @@ -166,7 +166,7 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn: easing = linear, tick = noop, css - } = config || (null_transition as TransitionConfig); + } = config || null_transition; if (css) animation_name = create_rule(node, 1, 0, duration, delay, easing, css); @@ -260,7 +260,7 @@ export function create_bidirectional_transition(node: Element & ElementCSSInline easing = linear, tick = noop, css - } = config || (null_transition as TransitionConfig); + } = config || null_transition; const program = { start: now() + delay,