fix some more transition bugs

pull/1971/head
Richard Harris 7 years ago
parent f72e152316
commit d48cb16217

@ -633,9 +633,15 @@ export default class ElementWrapper extends Wrapper {
block.builders.intro.addConditional(`@intros.enabled`, deindent` block.builders.intro.addConditional(`@intros.enabled`, deindent`
@add_render_callback(() => { @add_render_callback(() => {
${introName} = @create_transition(${this.var}, ${fn}, ${snippet}, true); ${introName} = @create_transition(${this.var}, ${fn}, ${snippet}, true);
${introName}.run(1); ${introName}.run(1, () => {
${introName} = null;
});
}); });
`); `);
block.builders.outro.addBlock(deindent`
if (${introName}) ${introName}.abort();
`);
} }
if (outro) { if (outro) {

@ -46,13 +46,14 @@ export function delete_rule(node, name) {
.filter(anim => anim.indexOf(name) < 0) .filter(anim => anim.indexOf(name) < 0)
.join(', '); .join(', ');
console.log({ active }); if (!--active) clear_rules();
if (--active <= 0) clear_rules();
} }
export function clear_rules() { export function clear_rules() {
console.log(`clear rules`, active); requestAnimationFrame(() => {
let i = stylesheet.cssRules.length; if (active) return;
while (i--) stylesheet.deleteRule(i); let i = stylesheet.cssRules.length;
current_rules = {}; while (i--) stylesheet.deleteRule(i);
current_rules = {};
});
} }

@ -26,7 +26,6 @@ export function group_outros() {
export function create_transition(node, fn, params, intro) { export function create_transition(node, fn, params, intro) {
let config = fn(node, params); let config = fn(node, params);
let cssText;
let ready = !intro; let ready = !intro;
let t = intro ? 0 : 1; let t = intro ? 0 : 1;
@ -50,8 +49,6 @@ export function create_transition(node, fn, params, intro) {
program.end = program.start + program.duration; program.end = program.start + program.duration;
if (config.css) { if (config.css) {
if (delay) node.style.cssText = cssText;
clear_animation(); clear_animation();
animation_name = create_rule(program, easing, config.css); animation_name = create_rule(program, easing, config.css);
@ -103,8 +100,9 @@ export function create_transition(node, fn, params, intro) {
if (!ready) { if (!ready) {
if (config.css && delay) { if (config.css && delay) {
cssText = node.style.cssText; // TODO can we just use the normal rule, but delay it?
node.style.cssText += config.css(0, 1); animation_name = create_rule({ a: 0, b: 1, d: 1, duration: 1, }, linear, () => config.css(0, 1));
node.style.animation = (node.style.animation ? ', ' : '') + `${animation_name} 9999s linear 1 both`;
} }
if (config.tick) config.tick(0, 1); if (config.tick) config.tick(0, 1);

Loading…
Cancel
Save