motion 10.1.3 → 10.3.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.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -0
- package/dist/main.cjs.js +4 -0
- package/dist/main.es.js +2 -0
- package/dist/motion.min.js +1 -1
- package/dist/motion.umd.js +524 -189
- package/dist/size-animate-dom.js +1 -1
- package/dist/size-animate-style.js +1 -1
- package/dist/size-react.js +1 -1
- package/dist/size-spring.js +1 -1
- package/dist/size-timeline-dom.js +1 -1
- package/dist/size-webpack-animate.js +1 -1
- package/dist/targets/dom/animate-style.cjs.js +136 -111
- package/dist/targets/dom/animate-style.es.js +139 -114
- package/dist/targets/dom/animate.cjs.js +16 -3
- package/dist/targets/dom/animate.es.js +17 -4
- package/dist/targets/dom/data.cjs.js +4 -2
- package/dist/targets/dom/data.es.js +4 -2
- package/dist/targets/dom/style.cjs.js +1 -1
- package/dist/targets/dom/style.es.js +2 -2
- package/dist/targets/dom/timeline/index.cjs.js +17 -7
- package/dist/targets/dom/timeline/index.es.js +18 -8
- package/dist/targets/dom/timeline/utils/calc-time.cjs.js +3 -1
- package/dist/targets/dom/timeline/utils/calc-time.es.js +3 -1
- package/dist/targets/dom/utils/apply.cjs.js +4 -8
- package/dist/targets/dom/utils/apply.es.js +3 -7
- package/dist/targets/dom/utils/controls.cjs.js +6 -2
- package/dist/targets/dom/utils/controls.es.js +6 -2
- package/dist/targets/dom/utils/css-var.cjs.js +2 -2
- package/dist/targets/dom/utils/css-var.es.js +3 -3
- package/dist/targets/dom/utils/easing.cjs.js +7 -2
- package/dist/targets/dom/utils/easing.es.js +7 -3
- package/dist/targets/dom/utils/feature-detection.cjs.js +4 -4
- package/dist/targets/dom/utils/feature-detection.es.js +4 -4
- package/dist/targets/dom/utils/get-style-name.cjs.js +13 -0
- package/dist/targets/dom/utils/get-style-name.es.js +9 -0
- package/dist/targets/dom/utils/keyframes.cjs.js +2 -4
- package/dist/targets/dom/utils/keyframes.es.js +2 -4
- package/dist/targets/dom/utils/options.cjs.js +1 -1
- package/dist/targets/dom/utils/options.es.js +1 -1
- package/dist/targets/dom/utils/stop-animation.cjs.js +2 -0
- package/dist/targets/dom/utils/stop-animation.es.js +2 -0
- package/dist/targets/dom/utils/transforms.cjs.js +10 -7
- package/dist/targets/dom/utils/transforms.es.js +10 -7
- package/dist/targets/js/{animate-number.cjs.js → NumberAnimation.cjs.js} +42 -29
- package/dist/targets/js/{animate-number.es.js → NumberAnimation.es.js} +43 -29
- package/dist/targets/js/easing/glide/generator.cjs.js +99 -0
- package/dist/targets/js/easing/glide/generator.es.js +95 -0
- package/dist/targets/js/easing/glide/index.cjs.js +10 -0
- package/dist/targets/js/easing/glide/index.es.js +6 -0
- package/dist/targets/js/easing/spring/generator.cjs.js +64 -0
- package/dist/targets/js/easing/spring/generator.es.js +57 -0
- package/dist/targets/js/easing/spring/index.cjs.js +10 -0
- package/dist/targets/js/easing/spring/index.es.js +6 -0
- package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +71 -0
- package/dist/targets/js/easing/utils/create-generator-easing.es.js +67 -0
- package/dist/targets/js/easing/{get-function.cjs.js → utils/get-function.cjs.js} +3 -3
- package/dist/targets/js/easing/{get-function.es.js → utils/get-function.es.js} +3 -3
- package/dist/targets/js/easing/utils/has-reached-target.cjs.js +10 -0
- package/dist/targets/js/easing/utils/has-reached-target.es.js +6 -0
- package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +34 -0
- package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +30 -0
- package/dist/targets/react/hooks/use-animation.cjs.js +5 -2
- package/dist/targets/react/hooks/use-animation.es.js +5 -2
- package/dist/targets/react/utils/keyframes.cjs.js +5 -3
- package/dist/targets/react/utils/keyframes.es.js +6 -4
- package/dist/utils/is-number.cjs.js +7 -0
- package/dist/utils/is-number.es.js +3 -0
- package/dist/utils/stagger.cjs.js +3 -2
- package/dist/utils/stagger.es.js +3 -2
- package/dist/utils/velocity-per-second.cjs.js +15 -0
- package/dist/utils/velocity-per-second.es.js +11 -0
- package/package.json +8 -14
- package/types/index.d.ts +2 -0
- package/types/targets/dom/animate-style.d.ts +2 -2
- package/types/targets/dom/data.d.ts +1 -7
- package/types/targets/dom/style.d.ts +1 -1
- package/types/targets/dom/types.d.ts +24 -18
- package/types/targets/dom/utils/apply.d.ts +3 -2
- package/types/targets/dom/utils/controls.d.ts +3 -3
- package/types/targets/dom/utils/easing.d.ts +2 -1
- package/types/targets/dom/utils/get-style-name.d.ts +1 -0
- package/types/targets/dom/utils/keyframes.d.ts +1 -1
- package/types/targets/dom/utils/stop-animation.d.ts +1 -1
- package/types/targets/dom/utils/transforms.d.ts +2 -2
- package/types/targets/js/{animate-number.d.ts → NumberAnimation.d.ts} +2 -3
- package/types/targets/js/easing/glide/generator.d.ts +5 -0
- package/types/targets/js/easing/glide/index.d.ts +2 -0
- package/types/targets/js/easing/glide/types.d.ts +14 -0
- package/types/targets/js/easing/spring/generator.d.ts +6 -0
- package/types/targets/js/easing/spring/index.d.ts +2 -0
- package/types/targets/js/easing/spring/types.d.ts +10 -0
- package/types/targets/js/easing/utils/create-generator-easing.d.ts +3 -0
- package/types/targets/js/easing/{get-function.d.ts → utils/get-function.d.ts} +2 -2
- package/types/targets/js/easing/utils/has-reached-target.d.ts +1 -0
- package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +7 -0
- package/types/targets/js/types.d.ts +11 -0
- package/types/utils/is-number.d.ts +1 -0
- package/types/generators/index.d.ts +0 -2
- package/types/generators/spring/create.d.ts +0 -13
- package/types/generators/spring/index.d.ts +0 -2
- package/types/generators/types.d.ts +0 -7
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import { animateStyle } from './animate-style.es.js';
|
|
2
2
|
import { getOptions } from './utils/options.es.js';
|
|
3
3
|
import { resolveElements } from './utils/resolve-elements.es.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createAnimations } from './utils/controls.es.js';
|
|
5
5
|
import { resolveOption } from '../../utils/stagger.es.js';
|
|
6
6
|
import { defaults } from './utils/defaults.es.js';
|
|
7
7
|
|
|
8
8
|
function animate(elements, keyframes, options = {}) {
|
|
9
9
|
var _a;
|
|
10
10
|
elements = resolveElements(elements);
|
|
11
|
-
const animations = [];
|
|
12
11
|
const numElements = elements.length;
|
|
12
|
+
/**
|
|
13
|
+
* Create and start new animations
|
|
14
|
+
*/
|
|
15
|
+
const animationFactories = [];
|
|
13
16
|
for (let i = 0; i < numElements; i++) {
|
|
14
17
|
const element = elements[i];
|
|
15
18
|
for (const key in keyframes) {
|
|
16
19
|
const valueOptions = getOptions(options, key);
|
|
17
20
|
valueOptions.delay = resolveOption(valueOptions.delay, i, numElements);
|
|
18
21
|
const animation = animateStyle(element, key, keyframes[key], valueOptions);
|
|
19
|
-
|
|
22
|
+
animationFactories.push(animation);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
|
-
return
|
|
25
|
+
return createAnimations(animationFactories,
|
|
26
|
+
/**
|
|
27
|
+
* TODO:
|
|
28
|
+
* If easing is set to spring or glide, duration will be dynamically
|
|
29
|
+
* generated. Ideally we would dynamically generate this from
|
|
30
|
+
* animation.effect.getComputedTiming().duration but this isn't
|
|
31
|
+
* supported in iOS13 or our number polyfill. Perhaps it's possible
|
|
32
|
+
* to Proxy animations returned from animateStyle that has duration
|
|
33
|
+
* as a getter.
|
|
34
|
+
*/
|
|
35
|
+
(_a = options.duration) !== null && _a !== void 0 ? _a : defaults.duration);
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
export { animate };
|
|
@@ -6,8 +6,10 @@ const data = new WeakMap();
|
|
|
6
6
|
function getAnimationData(element) {
|
|
7
7
|
if (!data.has(element)) {
|
|
8
8
|
data.set(element, {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
transforms: [],
|
|
10
|
+
animations: {},
|
|
11
|
+
generators: {},
|
|
12
|
+
prevGeneratorState: {},
|
|
11
13
|
});
|
|
12
14
|
}
|
|
13
15
|
return data.get(element);
|
|
@@ -2,8 +2,10 @@ const data = new WeakMap();
|
|
|
2
2
|
function getAnimationData(element) {
|
|
3
3
|
if (!data.has(element)) {
|
|
4
4
|
data.set(element, {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
transforms: [],
|
|
6
|
+
animations: {},
|
|
7
|
+
generators: {},
|
|
8
|
+
prevGeneratorState: {},
|
|
7
9
|
});
|
|
8
10
|
}
|
|
9
11
|
return data.get(element);
|
|
@@ -11,7 +11,7 @@ const style = {
|
|
|
11
11
|
? element.style.getPropertyValue(name)
|
|
12
12
|
: getComputedStyle(element)[name];
|
|
13
13
|
if (!value && value !== 0) {
|
|
14
|
-
const definition = transforms.
|
|
14
|
+
const definition = transforms.transformDefinitions.get(name);
|
|
15
15
|
if (definition)
|
|
16
16
|
value = definition.initialValue;
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isCssVar } from './utils/css-var.es.js';
|
|
2
|
-
import {
|
|
2
|
+
import { transformDefinitions } from './utils/transforms.es.js';
|
|
3
3
|
|
|
4
4
|
const style = {
|
|
5
5
|
get: (element, name) => {
|
|
@@ -7,7 +7,7 @@ const style = {
|
|
|
7
7
|
? element.style.getPropertyValue(name)
|
|
8
8
|
: getComputedStyle(element)[name];
|
|
9
9
|
if (!value && value !== 0) {
|
|
10
|
-
const definition =
|
|
10
|
+
const definition = transformDefinitions.get(name);
|
|
11
11
|
if (definition)
|
|
12
12
|
value = definition.initialValue;
|
|
13
13
|
}
|
|
@@ -18,13 +18,14 @@ var sort = require('./utils/sort.cjs.js');
|
|
|
18
18
|
|
|
19
19
|
function timeline(definition, options = {}) {
|
|
20
20
|
var _a, _b;
|
|
21
|
-
const animations = [];
|
|
22
21
|
const animationDefinitions = createAnimationsFromTimeline(definition, options);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Create and start animations
|
|
24
|
+
*/
|
|
25
|
+
const animationFactories = animationDefinitions
|
|
26
|
+
.map((definition) => animateStyle.animateStyle(...definition))
|
|
27
|
+
.filter(Boolean);
|
|
28
|
+
return controls.createAnimations(animationFactories,
|
|
28
29
|
// Get the duration from the first animation definition
|
|
29
30
|
(_b = (_a = animationDefinitions[0]) === null || _a === void 0 ? void 0 : _a[3].duration) !== null && _b !== void 0 ? _b : defaults.defaults.duration);
|
|
30
31
|
}
|
|
@@ -69,10 +70,19 @@ function createAnimationsFromTimeline(definition, _a = {}) {
|
|
|
69
70
|
const valueSequence = getValueSequence(key, elementSequence);
|
|
70
71
|
const valueKeyframes = keyframes.keyframesList(keyframes$1[key]);
|
|
71
72
|
const valueOptions = options.getOptions(options$1, key);
|
|
72
|
-
|
|
73
|
+
let { duration = defaultOptions.duration || defaults.defaults.duration, easing = defaultOptions.easing || defaults.defaults.easing, } = valueOptions;
|
|
73
74
|
const delay = stagger.resolveOption(options$1.delay, elementIndex, numElements) || 0;
|
|
74
75
|
const startTime = currentTime + delay;
|
|
75
76
|
const targetTime = startTime + duration;
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
let { offset: offset$1 = offset.defaultOffset(valueKeyframes.length) } = valueOptions;
|
|
81
|
+
/**
|
|
82
|
+
* If there's only one offset of 0, fill in a second with length 1
|
|
83
|
+
*
|
|
84
|
+
* TODO: Ensure there's a test that covers this removal
|
|
85
|
+
*/
|
|
76
86
|
if (offset$1.length === 1 && offset$1[0] === 0) {
|
|
77
87
|
offset$1[1] = 1;
|
|
78
88
|
}
|
|
@@ -3,7 +3,7 @@ import { progress } from '../../../utils/progress.es.js';
|
|
|
3
3
|
import { resolveOption } from '../../../utils/stagger.es.js';
|
|
4
4
|
import { defaultOffset, fillOffset } from '../../js/utils/offset.es.js';
|
|
5
5
|
import { animateStyle } from '../animate-style.es.js';
|
|
6
|
-
import {
|
|
6
|
+
import { createAnimations } from '../utils/controls.es.js';
|
|
7
7
|
import { defaults } from '../utils/defaults.es.js';
|
|
8
8
|
import { keyframesList } from '../utils/keyframes.es.js';
|
|
9
9
|
import { getOptions } from '../utils/options.es.js';
|
|
@@ -14,13 +14,14 @@ import { compareByTime } from './utils/sort.es.js';
|
|
|
14
14
|
|
|
15
15
|
function timeline(definition, options = {}) {
|
|
16
16
|
var _a, _b;
|
|
17
|
-
const animations = [];
|
|
18
17
|
const animationDefinitions = createAnimationsFromTimeline(definition, options);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Create and start animations
|
|
20
|
+
*/
|
|
21
|
+
const animationFactories = animationDefinitions
|
|
22
|
+
.map((definition) => animateStyle(...definition))
|
|
23
|
+
.filter(Boolean);
|
|
24
|
+
return createAnimations(animationFactories,
|
|
24
25
|
// Get the duration from the first animation definition
|
|
25
26
|
(_b = (_a = animationDefinitions[0]) === null || _a === void 0 ? void 0 : _a[3].duration) !== null && _b !== void 0 ? _b : defaults.duration);
|
|
26
27
|
}
|
|
@@ -65,10 +66,19 @@ function createAnimationsFromTimeline(definition, _a = {}) {
|
|
|
65
66
|
const valueSequence = getValueSequence(key, elementSequence);
|
|
66
67
|
const valueKeyframes = keyframesList(keyframes[key]);
|
|
67
68
|
const valueOptions = getOptions(options, key);
|
|
68
|
-
|
|
69
|
+
let { duration = defaultOptions.duration || defaults.duration, easing = defaultOptions.easing || defaults.easing, } = valueOptions;
|
|
69
70
|
const delay = resolveOption(options.delay, elementIndex, numElements) || 0;
|
|
70
71
|
const startTime = currentTime + delay;
|
|
71
72
|
const targetTime = startTime + duration;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
let { offset = defaultOffset(valueKeyframes.length) } = valueOptions;
|
|
77
|
+
/**
|
|
78
|
+
* If there's only one offset of 0, fill in a second with length 1
|
|
79
|
+
*
|
|
80
|
+
* TODO: Ensure there's a test that covers this removal
|
|
81
|
+
*/
|
|
72
82
|
if (offset.length === 1 && offset[0] === 0) {
|
|
73
83
|
offset[1] = 1;
|
|
74
84
|
}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var isNumber = require('../../../../utils/is-number.cjs.js');
|
|
6
|
+
|
|
5
7
|
function calcNextTime(current, next, prev, labels) {
|
|
6
8
|
var _a;
|
|
7
|
-
if (
|
|
9
|
+
if (isNumber.isNumber(next)) {
|
|
8
10
|
return next;
|
|
9
11
|
}
|
|
10
12
|
else if (next.startsWith("-") || next.startsWith("+")) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { isNumber } from '../../../../utils/is-number.es.js';
|
|
2
|
+
|
|
1
3
|
function calcNextTime(current, next, prev, labels) {
|
|
2
4
|
var _a;
|
|
3
|
-
if (
|
|
5
|
+
if (isNumber(next)) {
|
|
4
6
|
return next;
|
|
5
7
|
}
|
|
6
8
|
else if (next.startsWith("-") || next.startsWith("+")) {
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
const createStyleRenderer = (element, name) => {
|
|
9
|
-
return (latest) => (element.style[name] = latest);
|
|
10
|
-
};
|
|
5
|
+
const cssVariableRenderer = (element, name) => (latest) => element.style.setProperty(name, latest);
|
|
6
|
+
const styleRenderer = (element, name) => (latest) => (element.style[name] = latest);
|
|
11
7
|
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
8
|
+
exports.cssVariableRenderer = cssVariableRenderer;
|
|
9
|
+
exports.styleRenderer = styleRenderer;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
};
|
|
4
|
-
const createStyleRenderer = (element, name) => {
|
|
5
|
-
return (latest) => (element.style[name] = latest);
|
|
6
|
-
};
|
|
1
|
+
const cssVariableRenderer = (element, name) => (latest) => element.style.setProperty(name, latest);
|
|
2
|
+
const styleRenderer = (element, name) => (latest) => (element.style[name] = latest);
|
|
7
3
|
|
|
8
|
-
export {
|
|
4
|
+
export { cssVariableRenderer, styleRenderer };
|
|
@@ -6,7 +6,11 @@ var noop = require('../../../utils/noop.cjs.js');
|
|
|
6
6
|
var stopAnimation = require('./stop-animation.cjs.js');
|
|
7
7
|
var time = require('./time.cjs.js');
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const createAnimation = (factory) => factory();
|
|
10
|
+
const createAnimations = (animationFactory, duration) => new Proxy({
|
|
11
|
+
animations: animationFactory.map(createAnimation).filter(Boolean),
|
|
12
|
+
duration,
|
|
13
|
+
}, controls);
|
|
10
14
|
/**
|
|
11
15
|
* TODO:
|
|
12
16
|
* Currently this returns the first animation, ideally it would return
|
|
@@ -52,4 +56,4 @@ const controls = {
|
|
|
52
56
|
const selectFinished = (animation) => animation.finished;
|
|
53
57
|
|
|
54
58
|
exports.controls = controls;
|
|
55
|
-
exports.
|
|
59
|
+
exports.createAnimations = createAnimations;
|
|
@@ -2,7 +2,11 @@ import { noop } from '../../../utils/noop.es.js';
|
|
|
2
2
|
import { stopAnimation } from './stop-animation.es.js';
|
|
3
3
|
import { ms } from './time.es.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const createAnimation = (factory) => factory();
|
|
6
|
+
const createAnimations = (animationFactory, duration) => new Proxy({
|
|
7
|
+
animations: animationFactory.map(createAnimation).filter(Boolean),
|
|
8
|
+
duration,
|
|
9
|
+
}, controls);
|
|
6
10
|
/**
|
|
7
11
|
* TODO:
|
|
8
12
|
* Currently this returns the first animation, ideally it would return
|
|
@@ -47,4 +51,4 @@ const controls = {
|
|
|
47
51
|
};
|
|
48
52
|
const selectFinished = (animation) => animation.finished;
|
|
49
53
|
|
|
50
|
-
export { controls,
|
|
54
|
+
export { controls, createAnimations };
|
|
@@ -11,8 +11,8 @@ function registerCssVariable(name) {
|
|
|
11
11
|
return;
|
|
12
12
|
registeredProperties.add(name);
|
|
13
13
|
try {
|
|
14
|
-
const { syntax, initialValue } = transforms.
|
|
15
|
-
? transforms.
|
|
14
|
+
const { syntax, initialValue } = transforms.transformDefinitions.has(name)
|
|
15
|
+
? transforms.transformDefinitions.get(name)
|
|
16
16
|
: {};
|
|
17
17
|
CSS.registerProperty({
|
|
18
18
|
name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformDefinitions } from './transforms.es.js';
|
|
2
2
|
|
|
3
3
|
const isCssVar = (name) => name.startsWith("--");
|
|
4
4
|
const registeredProperties = new Set();
|
|
@@ -7,8 +7,8 @@ function registerCssVariable(name) {
|
|
|
7
7
|
return;
|
|
8
8
|
registeredProperties.add(name);
|
|
9
9
|
try {
|
|
10
|
-
const { syntax, initialValue } =
|
|
11
|
-
?
|
|
10
|
+
const { syntax, initialValue } = transformDefinitions.has(name)
|
|
11
|
+
? transformDefinitions.get(name)
|
|
12
12
|
: {};
|
|
13
13
|
CSS.registerProperty({
|
|
14
14
|
name,
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var isNumber = require('../../../utils/is-number.cjs.js');
|
|
6
|
+
|
|
7
|
+
const isCubicBezier = (easing) => Array.isArray(easing) && isNumber.isNumber(easing[0]);
|
|
8
|
+
const isEasingList = (easing) => Array.isArray(easing) && !isNumber.isNumber(easing[0]);
|
|
9
|
+
const isCustomEasing = (easing) => typeof easing === "object" &&
|
|
10
|
+
Boolean(easing.createAnimation);
|
|
7
11
|
const convertEasing = (easing) => isCubicBezier(easing) ? cubicBezierAsString(easing) : easing;
|
|
8
12
|
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
9
13
|
|
|
10
14
|
exports.convertEasing = convertEasing;
|
|
11
15
|
exports.cubicBezierAsString = cubicBezierAsString;
|
|
12
16
|
exports.isCubicBezier = isCubicBezier;
|
|
17
|
+
exports.isCustomEasing = isCustomEasing;
|
|
13
18
|
exports.isEasingList = isEasingList;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { isNumber } from '../../../utils/is-number.es.js';
|
|
2
|
+
|
|
3
|
+
const isCubicBezier = (easing) => Array.isArray(easing) && isNumber(easing[0]);
|
|
4
|
+
const isEasingList = (easing) => Array.isArray(easing) && !isNumber(easing[0]);
|
|
5
|
+
const isCustomEasing = (easing) => typeof easing === "object" &&
|
|
6
|
+
Boolean(easing.createAnimation);
|
|
3
7
|
const convertEasing = (easing) => isCubicBezier(easing) ? cubicBezierAsString(easing) : easing;
|
|
4
8
|
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
5
9
|
|
|
6
|
-
export { convertEasing, cubicBezierAsString, isCubicBezier, isEasingList };
|
|
10
|
+
export { convertEasing, cubicBezierAsString, isCubicBezier, isCustomEasing, isEasingList };
|
|
@@ -19,13 +19,13 @@ const featureTests = {
|
|
|
19
19
|
finished: () => Boolean(testAnimation({ opacity: [0, 1] }).finished),
|
|
20
20
|
};
|
|
21
21
|
const results = {};
|
|
22
|
-
const supports =
|
|
23
|
-
|
|
22
|
+
const supports = {};
|
|
23
|
+
for (const key in featureTests) {
|
|
24
|
+
supports[key] = () => {
|
|
24
25
|
if (results[key] === undefined)
|
|
25
26
|
results[key] = featureTests[key]();
|
|
26
27
|
return results[key];
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
}, {});
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
exports.supports = supports;
|
|
@@ -15,13 +15,13 @@ const featureTests = {
|
|
|
15
15
|
finished: () => Boolean(testAnimation({ opacity: [0, 1] }).finished),
|
|
16
16
|
};
|
|
17
17
|
const results = {};
|
|
18
|
-
const supports =
|
|
19
|
-
|
|
18
|
+
const supports = {};
|
|
19
|
+
for (const key in featureTests) {
|
|
20
|
+
supports[key] = () => {
|
|
20
21
|
if (results[key] === undefined)
|
|
21
22
|
results[key] = featureTests[key]();
|
|
22
23
|
return results[key];
|
|
23
24
|
};
|
|
24
|
-
|
|
25
|
-
}, {});
|
|
25
|
+
}
|
|
26
26
|
|
|
27
27
|
export { supports };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var transforms = require('./transforms.cjs.js');
|
|
6
|
+
|
|
7
|
+
function getStyleName(key) {
|
|
8
|
+
if (transforms.transformAlias[key])
|
|
9
|
+
key = transforms.transformAlias[key];
|
|
10
|
+
return transforms.isTransform(key) ? transforms.asTransformCssVar(key) : key;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.getStyleName = getStyleName;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isTransform, asTransformCssVar, transformAlias } from './transforms.es.js';
|
|
2
|
+
|
|
3
|
+
function getStyleName(key) {
|
|
4
|
+
if (transformAlias[key])
|
|
5
|
+
key = transformAlias[key];
|
|
6
|
+
return isTransform(key) ? asTransformCssVar(key) : key;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { getStyleName };
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function hydrateKeyframes(keyframes, element, name) {
|
|
5
|
+
function hydrateKeyframes(keyframes, readInitialValue) {
|
|
8
6
|
for (let i = 0; i < keyframes.length; i++) {
|
|
9
7
|
if (keyframes[i] === null) {
|
|
10
|
-
keyframes[i] = i ? keyframes[i - 1] :
|
|
8
|
+
keyframes[i] = i ? keyframes[i - 1] : readInitialValue();
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
return keyframes;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function hydrateKeyframes(keyframes, element, name) {
|
|
1
|
+
function hydrateKeyframes(keyframes, readInitialValue) {
|
|
4
2
|
for (let i = 0; i < keyframes.length; i++) {
|
|
5
3
|
if (keyframes[i] === null) {
|
|
6
|
-
keyframes[i] = i ? keyframes[i - 1] :
|
|
4
|
+
keyframes[i] = i ? keyframes[i - 1] : readInitialValue();
|
|
7
5
|
}
|
|
8
6
|
}
|
|
9
7
|
return keyframes;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const getOptions = (options, key) => options[key] ? Object.assign(Object.assign({}, options), options[key]) :
|
|
5
|
+
const getOptions = (options, key) => options[key] ? Object.assign(Object.assign({}, options), options[key]) : options;
|
|
6
6
|
|
|
7
7
|
exports.getOptions = getOptions;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const getOptions = (options, key) => options[key] ? Object.assign(Object.assign({}, options), options[key]) :
|
|
1
|
+
const getOptions = (options, key) => options[key] ? Object.assign(Object.assign({}, options), options[key]) : options;
|
|
2
2
|
|
|
3
3
|
export { getOptions };
|
|
@@ -40,7 +40,7 @@ const baseTransformProperties = {
|
|
|
40
40
|
},
|
|
41
41
|
skew: rotation,
|
|
42
42
|
};
|
|
43
|
-
const
|
|
43
|
+
const transformDefinitions = new Map();
|
|
44
44
|
const asTransformCssVar = (name) => `--motion-${name}`;
|
|
45
45
|
/**
|
|
46
46
|
* Generate a list of every possible transform key
|
|
@@ -49,7 +49,7 @@ const transforms = ["x", "y", "z"];
|
|
|
49
49
|
order.forEach((name) => {
|
|
50
50
|
axes.forEach((axis) => {
|
|
51
51
|
transforms.push(name + axis);
|
|
52
|
-
|
|
52
|
+
transformDefinitions.set(asTransformCssVar(name + axis), baseTransformProperties[name]);
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
/**
|
|
@@ -62,11 +62,14 @@ const compareTransformOrder = (a, b) => transforms.indexOf(a) - transforms.index
|
|
|
62
62
|
const transformLookup = new Set(transforms);
|
|
63
63
|
const isTransform = (name) => transformLookup.has(name);
|
|
64
64
|
const addTransformToElement = (element, name) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
// Map x to translateX etc
|
|
66
|
+
if (transformAlias[name])
|
|
67
|
+
name = transformAlias[name];
|
|
68
|
+
const { transforms } = data.getAnimationData(element);
|
|
69
|
+
array.addUniqueItem(transforms, name);
|
|
70
|
+
element.style.transform = buildTransformTemplate(transforms);
|
|
68
71
|
};
|
|
69
|
-
const buildTransformTemplate = (
|
|
72
|
+
const buildTransformTemplate = (transforms) => transforms
|
|
70
73
|
.sort(compareTransformOrder)
|
|
71
74
|
.reduce(transformListToString, "")
|
|
72
75
|
.trim();
|
|
@@ -79,4 +82,4 @@ exports.buildTransformTemplate = buildTransformTemplate;
|
|
|
79
82
|
exports.compareTransformOrder = compareTransformOrder;
|
|
80
83
|
exports.isTransform = isTransform;
|
|
81
84
|
exports.transformAlias = transformAlias;
|
|
82
|
-
exports.
|
|
85
|
+
exports.transformDefinitions = transformDefinitions;
|
|
@@ -36,7 +36,7 @@ const baseTransformProperties = {
|
|
|
36
36
|
},
|
|
37
37
|
skew: rotation,
|
|
38
38
|
};
|
|
39
|
-
const
|
|
39
|
+
const transformDefinitions = new Map();
|
|
40
40
|
const asTransformCssVar = (name) => `--motion-${name}`;
|
|
41
41
|
/**
|
|
42
42
|
* Generate a list of every possible transform key
|
|
@@ -45,7 +45,7 @@ const transforms = ["x", "y", "z"];
|
|
|
45
45
|
order.forEach((name) => {
|
|
46
46
|
axes.forEach((axis) => {
|
|
47
47
|
transforms.push(name + axis);
|
|
48
|
-
|
|
48
|
+
transformDefinitions.set(asTransformCssVar(name + axis), baseTransformProperties[name]);
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
/**
|
|
@@ -58,14 +58,17 @@ const compareTransformOrder = (a, b) => transforms.indexOf(a) - transforms.index
|
|
|
58
58
|
const transformLookup = new Set(transforms);
|
|
59
59
|
const isTransform = (name) => transformLookup.has(name);
|
|
60
60
|
const addTransformToElement = (element, name) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
// Map x to translateX etc
|
|
62
|
+
if (transformAlias[name])
|
|
63
|
+
name = transformAlias[name];
|
|
64
|
+
const { transforms } = getAnimationData(element);
|
|
65
|
+
addUniqueItem(transforms, name);
|
|
66
|
+
element.style.transform = buildTransformTemplate(transforms);
|
|
64
67
|
};
|
|
65
|
-
const buildTransformTemplate = (
|
|
68
|
+
const buildTransformTemplate = (transforms) => transforms
|
|
66
69
|
.sort(compareTransformOrder)
|
|
67
70
|
.reduce(transformListToString, "")
|
|
68
71
|
.trim();
|
|
69
72
|
const transformListToString = (template, name) => `${template} ${name}(var(${asTransformCssVar(name)}))`;
|
|
70
73
|
|
|
71
|
-
export { addTransformToElement, asTransformCssVar, axes, buildTransformTemplate, compareTransformOrder, isTransform, transformAlias,
|
|
74
|
+
export { addTransformToElement, asTransformCssVar, axes, buildTransformTemplate, compareTransformOrder, isTransform, transformAlias, transformDefinitions };
|