pull/4272/head
mtrelis 6 years ago
parent aac78219cc
commit fe634a8e04

@ -159,6 +159,19 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
group.r += 1; group.r += 1;
function started(){
add_render_callback(() => dispatch(node, false, 'start'));
}
function ended(){
dispatch(node, false, 'end');
if (!--group.r){
// this will result in `end()` being called,
// so we don't need to clean up here
run_all(group.c);
}
}
function go() { function go() {
const { const {
delay = 0, delay = 0,
@ -173,20 +186,14 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
const start_time = now() + delay; const start_time = now() + delay;
const end_time = start_time + duration; const end_time = start_time + duration;
add_render_callback(() => dispatch(node, false, 'start')); started();
loop(now => { loop(now => {
if (running) { if (running) {
if (now >= end_time) { if (now >= end_time) {
tick(0, 1); tick(0, 1);
dispatch(node, false, 'end'); ended();
if (!--group.r) {
// this will result in `end()` being called,
// so we don't need to clean up here
run_all(group.c);
}
return false; return false;
} }
@ -208,11 +215,8 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
go(); go();
}); });
} else if (config && config.then) { } else if (config && config.then) {
add_render_callback(() => dispatch(node, false, 'start')); started();
config.then(() => { config.then(ended).catch(ended)
dispatch(node, false, 'end');
if (!--group.r) run_all(group.c);
});
} else { } else {
go(); go();
} }

Loading…
Cancel
Save