remove animation before measuring

pull/10798/head
Rich Harris 2 years ago
parent 38cc2a63a8
commit 88d1287c54

@ -94,12 +94,12 @@ export function animation(element, get_fn, get_params) {
from = this.element.getBoundingClientRect(); from = this.element.getBoundingClientRect();
}, },
apply() { apply() {
animation?.abort();
to = this.element.getBoundingClientRect(); to = this.element.getBoundingClientRect();
const options = get_fn()(this.element, { from, to }, get_params?.()); const options = get_fn()(this.element, { from, to }, get_params?.());
animation?.abort();
if ( if (
from.left !== to.left || from.left !== to.left ||
from.right !== to.right || from.right !== to.right ||
@ -107,6 +107,7 @@ export function animation(element, get_fn, get_params) {
from.bottom !== to.bottom from.bottom !== to.bottom
) { ) {
animation = animate(this.element, options, undefined, 1, () => { animation = animate(this.element, options, undefined, 1, () => {
animation?.abort();
animation = undefined; animation = undefined;
}); });
} }

Loading…
Cancel
Save