From 5d0430e79577ba559d52af370cd45d14afe29d32 Mon Sep 17 00:00:00 2001 From: pushkine Date: Mon, 1 Jun 2020 22:56:36 +0200 Subject: [PATCH] fix --- src/runtime/internal/animations.ts | 7 ++++--- src/runtime/internal/loop.ts | 2 +- src/runtime/internal/transitions.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/runtime/internal/animations.ts b/src/runtime/internal/animations.ts index 4d65480c7c..5f18b073a5 100644 --- a/src/runtime/internal/animations.ts +++ b/src/runtime/internal/animations.ts @@ -2,10 +2,11 @@ import { run_transition } from './transitions'; import { methodify, noop } from './utils'; import { CssTransitionConfig } from 'svelte/transition'; -type AnimationFn = (node: Element, { from, to }: { from: DOMRect; to: DOMRect }, params: any) => CssTransitionConfig; +type Rect = DOMRect | ClientRect; +type AnimationFn = (node: Element, { from, to }: { from: Rect; to: Rect }, params: any) => CssTransitionConfig; export const run_animation = /*#__PURE__*/ methodify( - function run_animation(this: HTMLElement, from: DOMRect, fn: AnimationFn, params = {}) { + function run_animation(this: HTMLElement, from: Rect, fn: AnimationFn, params = {}) { if (!from) return noop; return run_transition( this, @@ -22,7 +23,7 @@ export const run_animation = /*#__PURE__*/ methodify( ); export const fix_position = /*#__PURE__*/ methodify( - function fix_position(this: HTMLElement, { left, top }: DOMRect) { + function fix_position(this: HTMLElement, { left, top }: Rect) { const { position, width, height, transform } = getComputedStyle(this); if (position === 'absolute' || position === 'fixed') return noop; const { position: og_position, width: og_width, height: og_height } = this.style; diff --git a/src/runtime/internal/loop.ts b/src/runtime/internal/loop.ts index c63bdd4000..993f565f63 100644 --- a/src/runtime/internal/loop.ts +++ b/src/runtime/internal/loop.ts @@ -84,7 +84,7 @@ export const setTweenTimeout = ( is_outro = false ): TaskCanceller => { let running = true; - let t = 1 - (end_time - now) / duration || 0; + let t = 1 - (end_time - now()) / duration || 0; if (!is_outro && t <= 1.0) run(t >= 0.0 ? t : 0); unsafe_loop((now) => { if (!running) return false; diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 088659858e..0776a4e5d6 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -61,7 +61,7 @@ const swap = (fn, rx) => ? (t) => fn(t, 1 - t) : (t) => fn(1 - t, t); -const mirrored = (fn, rx, easing) => { +const mirrored = (fn, rx, easing, _start, _end) => { const run = swap(fn, rx); return easing ? rx & tx.intro @@ -76,7 +76,7 @@ const reversed = (fn, rx, easing, start = 0, end = 1) => { ? (t) => run(start + difference * easing(t)) : (t) => run(start + difference * t); }; -export const enum tx { +const enum tx { intro = 1, outro = 2, reverse = 3,