@douyinfe/semi-animation 2.0.8 → 2.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import getEasing, { easingMap } from './src/getEasing';
2
+ import { events } from './src/constants';
3
+ export { default as Animation } from './src/Animation';
4
+ export { default as interpolate } from './src/interpolate';
5
+ export { default as presets } from './src/presets';
6
+ export { getEasing, easingMap, events };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
8
+
9
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
+
11
+ _Object$defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+
15
+ _Object$defineProperty(exports, "Animation", {
16
+ enumerable: true,
17
+ get: function () {
18
+ return _Animation.default;
19
+ }
20
+ });
21
+
22
+ _Object$defineProperty(exports, "easingMap", {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _getEasing.easingMap;
26
+ }
27
+ });
28
+
29
+ _Object$defineProperty(exports, "events", {
30
+ enumerable: true,
31
+ get: function () {
32
+ return _constants.events;
33
+ }
34
+ });
35
+
36
+ _Object$defineProperty(exports, "getEasing", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _getEasing.default;
40
+ }
41
+ });
42
+
43
+ _Object$defineProperty(exports, "interpolate", {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _interpolate.default;
47
+ }
48
+ });
49
+
50
+ _Object$defineProperty(exports, "presets", {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _presets.default;
54
+ }
55
+ });
56
+
57
+ var _getEasing = _interopRequireWildcard(require("./src/getEasing"));
58
+
59
+ var _constants = require("./src/constants");
60
+
61
+ var _Animation = _interopRequireDefault(require("./src/Animation"));
62
+
63
+ var _interpolate = _interopRequireDefault(require("./src/interpolate"));
64
+
65
+ var _presets = _interopRequireDefault(require("./src/presets"));
66
+
67
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
68
+
69
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,55 @@
1
+ import Event from './utils/Event';
2
+ /**
3
+ * @summary
4
+ *
5
+ * Lifecycle hook:
6
+ * start, pause, resume, stop, frame, rest
7
+ *
8
+ * Binding method:
9
+ * const animation = new Animation (); animation.on ('start | frame | rest ', () => {});
10
+ */
11
+ export default class Animation extends Event {
12
+ _config: Record<string, any>;
13
+ _props: Record<string, any>;
14
+ _from: Record<string, any>;
15
+ _to: Record<string, any>;
16
+ _delay: number;
17
+ _currentVelocity: Record<string, any>;
18
+ _currentStyle: Record<string, any>;
19
+ _lastIdealStyle: Record<string, any>;
20
+ _lastIdealVelocity: Record<string, any>;
21
+ _frameCount: number;
22
+ _prevTime: number;
23
+ _timer: any;
24
+ _startedTime: number;
25
+ _ended: boolean;
26
+ _stopped: boolean;
27
+ _wasAnimating: boolean;
28
+ _started: boolean;
29
+ _paused: boolean;
30
+ _accumulatedTime: Record<string, any>;
31
+ _pausedTime: number;
32
+ _destroyed: boolean;
33
+ constructor(props?: {}, config?: {});
34
+ _wrapConfig(object: {
35
+ [x: string]: any;
36
+ }, config: {
37
+ delay?: string;
38
+ }): {};
39
+ initStates(props?: Record<string, any>, config?: Record<string, any>): void;
40
+ animate(): void;
41
+ start(): void;
42
+ end(): void;
43
+ pause(): void;
44
+ resume(): void;
45
+ stop(): void;
46
+ destroy(): void;
47
+ resetPlayStates(): void;
48
+ reset(): void;
49
+ reverse(): void;
50
+ getCurrentStates(): {
51
+ [x: string]: any;
52
+ };
53
+ getInitialStates(): {};
54
+ getFinalStates(): {};
55
+ }
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.default = void 0;
12
+
13
+ var _now = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/date/now"));
14
+
15
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
16
+
17
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
18
+
19
+ var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
20
+
21
+ var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
22
+
23
+ var _Event = _interopRequireDefault(require("./utils/Event"));
24
+
25
+ var _shouldStopAnimation = _interopRequireDefault(require("./shouldStopAnimation"));
26
+
27
+ var _shouldUseBezier = _interopRequireDefault(require("./shouldUseBezier"));
28
+
29
+ var _stripStyle = _interopRequireDefault(require("./stripStyle"));
30
+
31
+ var _stepper = _interopRequireDefault(require("./stepper"));
32
+
33
+ var _mapToZero = _interopRequireDefault(require("./mapToZero"));
34
+
35
+ var _wrapValue = _interopRequireDefault(require("./wrapValue"));
36
+
37
+ /* eslint-disable max-depth */
38
+
39
+ /* eslint-disable eqeqeq */
40
+
41
+ /* eslint-disable max-lines-per-function */
42
+ const now = () => (0, _now.default)();
43
+
44
+ const msPerFrame = 1000 / 60;
45
+ /**
46
+ * @summary
47
+ *
48
+ * Lifecycle hook:
49
+ * start, pause, resume, stop, frame, rest
50
+ *
51
+ * Binding method:
52
+ * const animation = new Animation (); animation.on ('start | frame | rest ', () => {});
53
+ */
54
+
55
+ class Animation extends _Event.default {
56
+ constructor() {
57
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
58
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59
+ super();
60
+ this._props = (0, _assign.default)({}, props);
61
+ this._config = (0, _assign.default)({}, config);
62
+ this.initStates();
63
+ }
64
+
65
+ _wrapConfig(object, config) {
66
+ config = config && typeof config === 'object' ? config : this._config;
67
+ const ret = {};
68
+
69
+ for (const key of (0, _keys.default)(object)) {
70
+ ret[key] = (0, _wrapValue.default)(object[key], config);
71
+ }
72
+
73
+ return ret;
74
+ }
75
+
76
+ initStates(props, config) {
77
+ props = props && typeof props === 'object' ? props : this._props;
78
+ config = config && typeof config === 'object' ? config : this._config;
79
+ const {
80
+ from,
81
+ to
82
+ } = props;
83
+ this._from = {};
84
+
85
+ if (from && typeof from) {
86
+ for (const key of (0, _keys.default)(from)) {
87
+ this._from[key] = typeof from[key] === 'object' && from[key].val ? from[key].val : from[key];
88
+ }
89
+ }
90
+
91
+ this._to = this._wrapConfig(to, config);
92
+ this._delay = (0, _parseInt2.default)(config.delay) || 0;
93
+ const currentStyle = this._from && (0, _stripStyle.default)(this._from) || (0, _stripStyle.default)(this._to);
94
+ const currentVelocity = (0, _mapToZero.default)(currentStyle);
95
+ this._currentStyle = (0, _assign.default)({}, currentStyle);
96
+ this._currentVelocity = (0, _assign.default)({}, currentVelocity);
97
+ this._lastIdealStyle = (0, _assign.default)({}, currentStyle);
98
+ this._lastIdealVelocity = (0, _assign.default)({}, currentVelocity);
99
+ this.resetPlayStates();
100
+ this._frameCount = 0;
101
+ this._prevTime = 0;
102
+ }
103
+
104
+ animate() {
105
+ if (this._timer != null) {
106
+ return;
107
+ }
108
+
109
+ this._timer = requestAnimationFrame(timestamp => {
110
+ const nowTime = now(); // stop animation and emit onRest event
111
+
112
+ if ((0, _shouldStopAnimation.default)(this._currentStyle, this._to, this._currentVelocity, this._startedTime || nowTime, nowTime) || this._ended || this._stopped) {
113
+ if (this._wasAnimating && !this._ended && !this._stopped) {
114
+ // should emit reset in settimeout for delay msPerframe
115
+ this._timer = (0, _setTimeout2.default)(() => {
116
+ clearTimeout(this._timer);
117
+ this._timer = null;
118
+ this._ended = true;
119
+ this.emit('rest', this.getCurrentStates());
120
+ }, msPerFrame);
121
+ }
122
+
123
+ this.resetPlayStates();
124
+ return;
125
+ }
126
+
127
+ if (!this._started) {
128
+ this._started = true;
129
+ this.emit('start', this.getCurrentStates());
130
+ }
131
+
132
+ this._stopped = false;
133
+ this._paused = false;
134
+ this._wasAnimating = true;
135
+
136
+ if (this._startedTime === 0) {
137
+ this._startedTime = nowTime;
138
+ }
139
+
140
+ const currentTime = nowTime;
141
+ const timeDelta = currentTime - this._prevTime;
142
+ this._prevTime = currentTime;
143
+
144
+ if (currentTime - this._startedTime < this._delay) {
145
+ this._timer = null;
146
+ this.animate();
147
+ }
148
+
149
+ const newLastIdealStyle = {};
150
+ const newLastIdealVelocity = {};
151
+ const newCurrentStyle = {};
152
+ const newCurrentVelocity = {};
153
+ const toKeys = this._to && (0, _keys.default)(this._to) || [];
154
+
155
+ for (const key of toKeys) {
156
+ const styleValue = this._to[key];
157
+ this._accumulatedTime[key] = typeof this._accumulatedTime[key] !== 'number' ? timeDelta : this._accumulatedTime[key] + timeDelta;
158
+ const from = this._from[key] != null && typeof this._from[key] === 'object' ? this._from[key].val : this._from[key];
159
+ const to = styleValue.val;
160
+
161
+ if (typeof styleValue === 'number') {
162
+ newCurrentStyle[key] = styleValue;
163
+ newCurrentVelocity[key] = 0;
164
+ newLastIdealStyle[key] = styleValue;
165
+ newLastIdealVelocity[key] = 0;
166
+ } else {
167
+ let newLastIdealStyleValue = this._lastIdealStyle[key];
168
+ let newLastIdealVelocityValue = this._lastIdealVelocity[key];
169
+
170
+ if ((0, _shouldUseBezier.default)(this._config) || (0, _shouldUseBezier.default)(styleValue)) {
171
+ // easing
172
+ const {
173
+ easing,
174
+ duration
175
+ } = styleValue;
176
+ newLastIdealStyleValue = from + easing((currentTime - this._startedTime) / duration) * (to - from);
177
+
178
+ if (currentTime >= this._startedTime + duration) {
179
+ newLastIdealStyleValue = to;
180
+ styleValue.done = true;
181
+ }
182
+
183
+ newLastIdealStyle[key] = newLastIdealStyleValue;
184
+ newCurrentStyle[key] = newLastIdealStyleValue;
185
+ } else if (to != null && to === this._currentStyle[key]) {
186
+ newCurrentStyle[key] = to;
187
+ newCurrentVelocity[key] = 0;
188
+ newLastIdealStyle[key] = to;
189
+ newLastIdealVelocity[key] = 0;
190
+ } else {
191
+ // spring
192
+ const currentFrameCompletion = (this._accumulatedTime[key] - Math.floor(this._accumulatedTime[key] / msPerFrame) * msPerFrame) / msPerFrame;
193
+ const framesToCatchUp = Math.floor(this._accumulatedTime[key] / msPerFrame);
194
+
195
+ for (let i = 0; i < framesToCatchUp; i++) {
196
+ [newLastIdealStyleValue, newLastIdealVelocityValue] = (0, _stepper.default)(msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.tension, styleValue.friction, styleValue.precision);
197
+ }
198
+
199
+ const [nextIdealX, nextIdealV] = (0, _stepper.default)(msPerFrame / 1000, newLastIdealStyleValue, newLastIdealVelocityValue, styleValue.val, styleValue.tension, styleValue.friction, styleValue.precision);
200
+ newCurrentStyle[key] = newLastIdealStyleValue + (nextIdealX - newLastIdealStyleValue) * currentFrameCompletion;
201
+ newCurrentVelocity[key] = newLastIdealVelocityValue + (nextIdealV - newLastIdealVelocityValue) * currentFrameCompletion;
202
+ newLastIdealStyle[key] = newLastIdealStyleValue;
203
+ newLastIdealVelocity[key] = newLastIdealVelocityValue;
204
+ this._accumulatedTime[key] -= framesToCatchUp * msPerFrame;
205
+ }
206
+ }
207
+ }
208
+
209
+ this._timer = null;
210
+ this._currentStyle = (0, _assign.default)({}, newCurrentStyle);
211
+ this._currentVelocity = (0, _assign.default)({}, newCurrentVelocity);
212
+ this._lastIdealStyle = (0, _assign.default)({}, newLastIdealStyle);
213
+ this._lastIdealVelocity = (0, _assign.default)({}, newLastIdealVelocity); // console.log(newCurrentStyle);
214
+
215
+ if (!this._destroyed) {
216
+ this.emit('frame', this.getCurrentStates());
217
+ this.animate();
218
+ }
219
+ });
220
+ }
221
+
222
+ start() {
223
+ this._prevTime = now();
224
+ this._startedTime = now();
225
+ this.animate();
226
+ }
227
+
228
+ end() {
229
+ if (!this._ended) {
230
+ this._ended = true;
231
+ this._currentStyle = this.getFinalStates();
232
+ this.emit('frame', this.getFinalStates());
233
+ this.emit('rest', this.getFinalStates());
234
+ }
235
+
236
+ this.destroy();
237
+ }
238
+
239
+ pause() {
240
+ if (!this._paused) {
241
+ this._pausedTime = now();
242
+ this._paused = true;
243
+ this.emit('pause', this.getCurrentStates());
244
+ this.destroy();
245
+ this._destroyed = false;
246
+ }
247
+ }
248
+
249
+ resume() {
250
+ if (this._started && this._paused) {
251
+ const nowTime = now();
252
+ const pausedDuration = nowTime - this._pausedTime;
253
+ this._paused = false; // should add with pausedDuration
254
+
255
+ this._startedTime += pausedDuration;
256
+ this._prevTime += pausedDuration;
257
+ this._pausedTime = 0;
258
+ this.emit('resume', this.getCurrentStates());
259
+ this.animate();
260
+ }
261
+ }
262
+
263
+ stop() {
264
+ this.destroy();
265
+
266
+ if (!this._stopped) {
267
+ this._stopped = true; // this.emit('frame', this.getInitialStates());
268
+
269
+ this.emit('stop', this.getInitialStates());
270
+ this.initStates();
271
+ }
272
+ }
273
+
274
+ destroy() {
275
+ cancelAnimationFrame(this._timer);
276
+ clearTimeout(this._timer);
277
+ this._timer = null;
278
+ this._destroyed = true;
279
+ }
280
+
281
+ resetPlayStates() {
282
+ this._started = false;
283
+ this._stopped = false;
284
+ this._ended = false;
285
+ this._paused = false;
286
+ this._destroyed = false;
287
+ this._timer = null;
288
+ this._wasAnimating = false;
289
+ this._accumulatedTime = {};
290
+ this._startedTime = 0;
291
+ this._pausedTime = 0;
292
+ }
293
+
294
+ reset() {
295
+ this.destroy();
296
+ this.initStates();
297
+ }
298
+
299
+ reverse() {
300
+ this.destroy();
301
+ const props = (0, _assign.default)({}, this._props);
302
+ const [from, to] = [props.to, props.from];
303
+ props.from = from;
304
+ props.to = to;
305
+ this._props = (0, _assign.default)({}, props);
306
+ this.initStates();
307
+ }
308
+
309
+ getCurrentStates() {
310
+ return (0, _assign.default)({}, this._currentStyle);
311
+ }
312
+
313
+ getInitialStates() {
314
+ return (0, _assign.default)({}, (0, _stripStyle.default)(this._props.from));
315
+ }
316
+
317
+ getFinalStates() {
318
+ return (0, _assign.default)({}, (0, _stripStyle.default)(this._props.to));
319
+ }
320
+
321
+ }
322
+
323
+ exports.default = Animation;
@@ -0,0 +1 @@
1
+ export declare const events: string[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+
9
+ exports.events = void 0;
10
+ const events = ['start', 'frame', 'pause', 'resume', 'stop', 'rest'];
11
+ exports.events = events;
@@ -0,0 +1,10 @@
1
+ export declare type BezierArgs = [number, number, number, number];
2
+ export declare const easingMap: {
3
+ linear: number[];
4
+ };
5
+ /**
6
+ * get easing function
7
+ * @param {string|Function} easing
8
+ * @returns {Function}
9
+ */
10
+ export default function getEasing(easing: string): any;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.default = getEasing;
12
+ exports.easingMap = void 0;
13
+
14
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
15
+
16
+ var _parseFloat2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-float"));
17
+
18
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
19
+
20
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
21
+
22
+ var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
23
+
24
+ var _bezierEasing = _interopRequireDefault(require("bezier-easing"));
25
+
26
+ function minMax(val, min, max) {
27
+ return Math.min(Math.max(val, min), max);
28
+ }
29
+
30
+ function parseEasingParameters(string) {
31
+ var _context;
32
+
33
+ const match = /\(([^)]+)\)/.exec(string);
34
+ return match ? (0, _map.default)(_context = match[1].split(',')).call(_context, p => (0, _parseFloat2.default)(p)) : [];
35
+ } // Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/
36
+
37
+
38
+ function elastic() {
39
+ let amplitude = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
40
+ let period = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
41
+ const a = minMax(amplitude, 1, 10);
42
+ const p = minMax(period, 0.1, 2);
43
+ return t => t === 0 || t === 1 ? t : -a * Math.pow(2, 10 * (t - 1)) * Math.sin((t - 1 - p / (Math.PI * 2) * Math.asin(1 / a)) * (Math.PI * 2) / p);
44
+ } // anime.js/src/index.js
45
+
46
+
47
+ const easingMap = (() => {
48
+ const names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Sine', 'Expo', 'Circ', 'Back', 'Elastic']; // Approximated Penner equations http://matthewlein.com/ceaser/
49
+
50
+ const curves = {
51
+ In: [[0.55, 0.085, 0.68, 0.53]
52
+ /* inQuad */
53
+ , [0.55, 0.055, 0.675, 0.19]
54
+ /* inCubic */
55
+ , [0.895, 0.03, 0.685, 0.22]
56
+ /* inQuart */
57
+ , [0.755, 0.05, 0.855, 0.06]
58
+ /* inQuint */
59
+ , [0.47, 0.0, 0.745, 0.715]
60
+ /* inSine */
61
+ , [0.95, 0.05, 0.795, 0.035]
62
+ /* inExpo */
63
+ , [0.6, 0.04, 0.98, 0.335]
64
+ /* inCirc */
65
+ , [0.6, -0.28, 0.735, 0.045]
66
+ /* inBack */
67
+ , elastic
68
+ /* inElastic */
69
+ ],
70
+ Out: [[0.25, 0.46, 0.45, 0.94]
71
+ /* outQuad */
72
+ , [0.215, 0.61, 0.355, 1.0]
73
+ /* outCubic */
74
+ , [0.165, 0.84, 0.44, 1.0]
75
+ /* outQuart */
76
+ , [0.23, 1.0, 0.32, 1.0]
77
+ /* outQuint */
78
+ , [0.39, 0.575, 0.565, 1.0]
79
+ /* outSine */
80
+ , [0.19, 1.0, 0.22, 1.0]
81
+ /* outExpo */
82
+ , [0.075, 0.82, 0.165, 1.0]
83
+ /* outCirc */
84
+ , [0.175, 0.885, 0.32, 1.275]
85
+ /* outBack */
86
+ , (a, p) => t => 1 - elastic(a, p)(1 - t)
87
+ /* outElastic */
88
+ ],
89
+ InOut: [[0.455, 0.03, 0.515, 0.955]
90
+ /* inOutQuad */
91
+ , [0.645, 0.045, 0.355, 1.0]
92
+ /* inOutCubic */
93
+ , [0.77, 0.0, 0.175, 1.0]
94
+ /* inOutQuart */
95
+ , [0.86, 0.0, 0.07, 1.0]
96
+ /* inOutQuint */
97
+ , [0.445, 0.05, 0.55, 0.95]
98
+ /* inOutSine */
99
+ , [1.0, 0.0, 0.0, 1.0]
100
+ /* inOutExpo */
101
+ , [0.785, 0.135, 0.15, 0.86]
102
+ /* inOutCirc */
103
+ , [0.68, -0.55, 0.265, 1.55]
104
+ /* inOutBack */
105
+ , (a, p) => t => t < 0.5 ? elastic(a, p)(t * 2) / 2 : 1 - elastic(a, p)(t * -2 + 2) / 2
106
+ /* inOutElastic */
107
+ ]
108
+ };
109
+ const eases = {
110
+ linear: [0.25, 0.25, 0.75, 0.75]
111
+ };
112
+
113
+ for (const coords of (0, _keys.default)(curves)) {
114
+ var _context2;
115
+
116
+ (0, _forEach.default)(_context2 = curves[coords]).call(_context2, (ease, i) => {
117
+ eases['ease' + coords + names[i]] = ease;
118
+ });
119
+ }
120
+
121
+ return eases;
122
+ })();
123
+ /**
124
+ * get easing function
125
+ * @param {string|Function} easing
126
+ * @returns {Function}
127
+ */
128
+
129
+
130
+ exports.easingMap = easingMap;
131
+
132
+ function getEasing(easing) {
133
+ if (typeof easing === 'function') {
134
+ return easing;
135
+ }
136
+
137
+ if (!easing || typeof easing !== 'string') {
138
+ easing = 'linear';
139
+ } else {
140
+ easing = (0, _trim.default)(easing).call(easing);
141
+ }
142
+
143
+ let name = easing.split('(')[0];
144
+ const args = parseEasingParameters(easing);
145
+ let ease;
146
+
147
+ if (name === 'cubic-bezier' || name === 'cubicBezier') {
148
+ return (0, _bezierEasing.default)(...(args.length ? args : easingMap.linear));
149
+ } else {
150
+ // eslint-disable-next-line eqeqeq
151
+ if (!name || typeof name !== 'string' || typeof name === 'string' && easingMap[name] == null) {
152
+ name = 'linear';
153
+ }
154
+
155
+ ease = easingMap[name];
156
+
157
+ if (typeof ease === 'function') {
158
+ return ease(...args);
159
+ } else if (args.length) {
160
+ return (0, _bezierEasing.default)(...args);
161
+ } else {
162
+ return (0, _bezierEasing.default)(...ease);
163
+ }
164
+ }
165
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ *
3
+ * @param {number|number[]|string|string[]} from
4
+ * @param {number|number[]|string|string[]} to
5
+ * @param {number} ratio
6
+ * @param {Function} [parser]
7
+ * @param {Function} [formatter]
8
+ * @returns {any}
9
+ */
10
+ export declare type FromTo = string | number | (string | number)[];
11
+ export declare type Parser = (value: FromTo) => any;
12
+ export declare type Formatter = (value: any[]) => any;
13
+ export default function interpolate(from: FromTo, to: FromTo, ratio?: number, parser?: Parser, formatter?: Formatter): any;