UNPKG

963 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var easing = require('../easing');
6var internal = require('../internal');
7
8function flip(node, animation, params) {
9 const style = getComputedStyle(node);
10 const transform = style.transform === 'none' ? '' : style.transform;
11 const scaleX = animation.from.width / node.clientWidth;
12 const scaleY = animation.from.height / node.clientHeight;
13 const dx = (animation.from.left - animation.to.left) / scaleX;
14 const dy = (animation.from.top - animation.to.top) / scaleY;
15 const d = Math.sqrt(dx * dx + dy * dy);
16 const { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing: easing$1 = easing.cubicOut } = params;
17 return {
18 delay,
19 duration: internal.is_function(duration) ? duration(d) : duration,
20 easing: easing$1,
21 css: (_t, u) => `transform: ${transform} translate(${u * dx}px, ${u * dy}px);`
22 };
23}
24
25exports.flip = flip;