UNPKG

817 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 dx = animation.from.left - animation.to.left;
12 const dy = animation.from.top - animation.to.top;
13 const d = Math.sqrt(dx * dx + dy * dy);
14 const { delay = 0, duration = d => Math.sqrt(d) * 120, easing: easing$1 = easing.cubicOut } = params;
15 return {
16 delay,
17 duration: internal.is_function(duration) ? duration(d) : duration,
18 easing: easing$1,
19 css: (_t, u) => `transform: ${transform} translate(${u * dx}px, ${u * dy}px);`
20 };
21}
22
23exports.flip = flip;