Optimazing flip function

pull/9026/head
Mike 3 years ago
parent 7af165de09
commit 1c6a62f0c5

@ -14,7 +14,7 @@ import { is_function } from '../internal/index.js';
export function flip(node, { from, to }, params = {}) { export function flip(node, { from, to }, params = {}) {
const style = getComputedStyle(node); const style = getComputedStyle(node);
const transform = style.transform === 'none' ? '' : style.transform; const transform = style.transform === 'none' ? '' : style.transform;
const [ox, oy] = style.transformOrigin.split(' ').map(parseFloat); const {0: ox, 1: oy} = style.transformOrigin.split(' ').map(parseFloat);
const dx = from.left + (from.width * ox) / to.width - (to.left + ox); const dx = from.left + (from.width * ox) / to.width - (to.left + ox);
const dy = from.top + (from.height * oy) / to.height - (to.top + oy); const dy = from.top + (from.height * oy) / to.height - (to.top + oy);
const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params; const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params;

Loading…
Cancel
Save