Skip to content

Commit

Permalink
Merge pull request #2246 from sveltejs/null-transition
Browse files Browse the repository at this point in the history
allow transition functions to return nothing
  • Loading branch information
Rich-Harris authored Aug 5, 2019
2 parents 9addc5f + c069aba commit d61387d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/runtime/internal/transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export function transition_out(block, local: 0 | 1, detach: 0 | 1, callback) {
}
}

const null_transition: TransitionConfig = { duration: 0 };

type TransitionFn = (node: Element, params: any) => TransitionConfig;

export function create_in_transition(node: Element & ElementCSSInlineStyle, fn: TransitionFn, params: any) {
Expand All @@ -85,7 +87,7 @@ export function create_in_transition(node: Element & ElementCSSInlineStyle, fn:
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);
Expand Down Expand Up @@ -164,7 +166,7 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
easing = linear,
tick = noop,
css
} = config;
} = config || null_transition;

if (css) animation_name = create_rule(node, 1, 0, duration, delay, easing, css);

Expand Down Expand Up @@ -258,7 +260,7 @@ export function create_bidirectional_transition(node: Element & ElementCSSInline
easing = linear,
tick = noop,
css
} = config;
} = config || null_transition;

const program = {
start: now() + delay,
Expand Down

0 comments on commit d61387d

Please sign in to comment.