motion 10.3.0 → 10.5.0-alpha.1
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/README.md +0 -19
- package/dist/main.cjs.js +11 -13
- package/dist/main.es.js +7 -6
- package/dist/motion.min.js +1 -1
- package/dist/motion.umd.js +8 -1264
- package/dist/size-index.js +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/package.json +5 -137
- package/types/index.d.ts +3 -7
- package/types/index.d.ts.map +1 -0
- package/CHANGELOG.md +0 -85
- package/LICENSE +0 -21
- package/dist/react.cjs.js +0 -9
- package/dist/react.es.js +0 -1
- package/dist/size-animate-dom.js +0 -1
- package/dist/size-animate-style.js +0 -1
- package/dist/size-react.js +0 -1
- package/dist/size-spring.js +0 -1
- package/dist/size-timeline-dom.js +0 -1
- package/dist/size-webpack-animate.js +0 -1
- package/dist/targets/dom/animate-style.cjs.js +0 -182
- package/dist/targets/dom/animate-style.es.js +0 -178
- package/dist/targets/dom/animate.cjs.js +0 -42
- package/dist/targets/dom/animate.es.js +0 -38
- package/dist/targets/dom/data.cjs.js +0 -18
- package/dist/targets/dom/data.es.js +0 -14
- package/dist/targets/dom/style.cjs.js +0 -22
- package/dist/targets/dom/style.es.js +0 -18
- package/dist/targets/dom/timeline/index.cjs.js +0 -174
- package/dist/targets/dom/timeline/index.es.js +0 -169
- package/dist/targets/dom/timeline/utils/calc-time.cjs.js +0 -23
- package/dist/targets/dom/timeline/utils/calc-time.es.js +0 -19
- package/dist/targets/dom/timeline/utils/edit.cjs.js +0 -36
- package/dist/targets/dom/timeline/utils/edit.es.js +0 -31
- package/dist/targets/dom/timeline/utils/sort.cjs.js +0 -14
- package/dist/targets/dom/timeline/utils/sort.es.js +0 -10
- package/dist/targets/dom/utils/apply.cjs.js +0 -9
- package/dist/targets/dom/utils/apply.es.js +0 -4
- package/dist/targets/dom/utils/controls.cjs.js +0 -59
- package/dist/targets/dom/utils/controls.es.js +0 -54
- package/dist/targets/dom/utils/css-var.cjs.js +0 -29
- package/dist/targets/dom/utils/css-var.es.js +0 -23
- package/dist/targets/dom/utils/defaults.cjs.js +0 -13
- package/dist/targets/dom/utils/defaults.es.js +0 -9
- package/dist/targets/dom/utils/easing.cjs.js +0 -18
- package/dist/targets/dom/utils/easing.es.js +0 -10
- package/dist/targets/dom/utils/feature-detection.cjs.js +0 -31
- package/dist/targets/dom/utils/feature-detection.es.js +0 -27
- package/dist/targets/dom/utils/get-style-name.cjs.js +0 -13
- package/dist/targets/dom/utils/get-style-name.es.js +0 -9
- package/dist/targets/dom/utils/keyframes.cjs.js +0 -16
- package/dist/targets/dom/utils/keyframes.es.js +0 -11
- package/dist/targets/dom/utils/options.cjs.js +0 -7
- package/dist/targets/dom/utils/options.es.js +0 -3
- package/dist/targets/dom/utils/resolve-elements.cjs.js +0 -22
- package/dist/targets/dom/utils/resolve-elements.es.js +0 -18
- package/dist/targets/dom/utils/stop-animation.cjs.js +0 -19
- package/dist/targets/dom/utils/stop-animation.es.js +0 -15
- package/dist/targets/dom/utils/time.cjs.js +0 -7
- package/dist/targets/dom/utils/time.es.js +0 -3
- package/dist/targets/dom/utils/transforms.cjs.js +0 -85
- package/dist/targets/dom/utils/transforms.es.js +0 -74
- package/dist/targets/js/NumberAnimation.cjs.js +0 -144
- package/dist/targets/js/NumberAnimation.es.js +0 -140
- package/dist/targets/js/easing/cubic-bezier.cjs.js +0 -57
- package/dist/targets/js/easing/cubic-bezier.es.js +0 -53
- package/dist/targets/js/easing/glide/generator.cjs.js +0 -99
- package/dist/targets/js/easing/glide/generator.es.js +0 -95
- package/dist/targets/js/easing/glide/index.cjs.js +0 -10
- package/dist/targets/js/easing/glide/index.es.js +0 -6
- package/dist/targets/js/easing/spring/generator.cjs.js +0 -64
- package/dist/targets/js/easing/spring/generator.es.js +0 -57
- package/dist/targets/js/easing/spring/index.cjs.js +0 -10
- package/dist/targets/js/easing/spring/index.es.js +0 -6
- package/dist/targets/js/easing/steps.cjs.js +0 -15
- package/dist/targets/js/easing/steps.es.js +0 -11
- package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +0 -71
- package/dist/targets/js/easing/utils/create-generator-easing.es.js +0 -67
- package/dist/targets/js/easing/utils/get-function.cjs.js +0 -37
- package/dist/targets/js/easing/utils/get-function.es.js +0 -33
- package/dist/targets/js/easing/utils/has-reached-target.cjs.js +0 -10
- package/dist/targets/js/easing/utils/has-reached-target.es.js +0 -6
- package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +0 -34
- package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +0 -30
- package/dist/targets/js/utils/get-easing.cjs.js +0 -14
- package/dist/targets/js/utils/get-easing.es.js +0 -10
- package/dist/targets/js/utils/interpolate.cjs.js +0 -35
- package/dist/targets/js/utils/interpolate.es.js +0 -31
- package/dist/targets/js/utils/offset.cjs.js +0 -22
- package/dist/targets/js/utils/offset.es.js +0 -17
- package/dist/targets/react/animated.cjs.js +0 -126
- package/dist/targets/react/animated.es.js +0 -101
- package/dist/targets/react/context.cjs.js +0 -9
- package/dist/targets/react/context.es.js +0 -5
- package/dist/targets/react/hooks/use-animation.cjs.js +0 -47
- package/dist/targets/react/hooks/use-animation.es.js +0 -43
- package/dist/targets/react/hooks/use-exit.cjs.js +0 -27
- package/dist/targets/react/hooks/use-exit.es.js +0 -23
- package/dist/targets/react/hooks/use-gesture-state.cjs.js +0 -17
- package/dist/targets/react/hooks/use-gesture-state.es.js +0 -13
- package/dist/targets/react/hooks/use-hover.cjs.js +0 -24
- package/dist/targets/react/hooks/use-hover.es.js +0 -20
- package/dist/targets/react/hooks/use-press.cjs.js +0 -25
- package/dist/targets/react/hooks/use-press.es.js +0 -21
- package/dist/targets/react/hooks/use-viewport.cjs.js +0 -37
- package/dist/targets/react/hooks/use-viewport.es.js +0 -33
- package/dist/targets/react/index.cjs.js +0 -17
- package/dist/targets/react/index.es.js +0 -13
- package/dist/targets/react/utils/has-changed.cjs.js +0 -24
- package/dist/targets/react/utils/has-changed.es.js +0 -19
- package/dist/targets/react/utils/keyframes.cjs.js +0 -38
- package/dist/targets/react/utils/keyframes.es.js +0 -34
- package/dist/targets/react/utils/poses.cjs.js +0 -14
- package/dist/targets/react/utils/poses.es.js +0 -10
- package/dist/targets/react/utils/update-target.cjs.js +0 -20
- package/dist/targets/react/utils/update-target.es.js +0 -16
- package/dist/utils/array.cjs.js +0 -14
- package/dist/utils/array.es.js +0 -9
- package/dist/utils/clamp.cjs.js +0 -7
- package/dist/utils/clamp.es.js +0 -3
- package/dist/utils/is-number.cjs.js +0 -7
- package/dist/utils/is-number.es.js +0 -3
- package/dist/utils/mix.cjs.js +0 -28
- package/dist/utils/mix.es.js +0 -24
- package/dist/utils/noop.cjs.js +0 -9
- package/dist/utils/noop.es.js +0 -4
- package/dist/utils/progress.cjs.js +0 -20
- package/dist/utils/progress.es.js +0 -16
- package/dist/utils/stagger.cjs.js +0 -38
- package/dist/utils/stagger.es.js +0 -32
- package/dist/utils/velocity-per-second.cjs.js +0 -15
- package/dist/utils/velocity-per-second.es.js +0 -11
- package/dist/utils/wrap.cjs.js +0 -10
- package/dist/utils/wrap.es.js +0 -6
- package/react/package.json +0 -6
- package/types/react-entry.d.ts +0 -2
- package/types/targets/dom/animate-style.d.ts +0 -2
- package/types/targets/dom/animate.d.ts +0 -2
- package/types/targets/dom/data.d.ts +0 -2
- package/types/targets/dom/style.d.ts +0 -3
- package/types/targets/dom/timeline/index.d.ts +0 -15
- package/types/targets/dom/timeline/types.d.ts +0 -13
- package/types/targets/dom/timeline/utils/calc-time.d.ts +0 -2
- package/types/targets/dom/timeline/utils/edit.d.ts +0 -4
- package/types/targets/dom/timeline/utils/sort.d.ts +0 -2
- package/types/targets/dom/types.d.ts +0 -114
- package/types/targets/dom/utils/apply.d.ts +0 -3
- package/types/targets/dom/utils/controls.d.ts +0 -12
- package/types/targets/dom/utils/css-var.d.ts +0 -3
- package/types/targets/dom/utils/defaults.d.ts +0 -8
- package/types/targets/dom/utils/easing.d.ts +0 -6
- package/types/targets/dom/utils/feature-detection.d.ts +0 -8
- package/types/targets/dom/utils/get-style-name.d.ts +0 -1
- package/types/targets/dom/utils/keyframes.d.ts +0 -3
- package/types/targets/dom/utils/options.d.ts +0 -2
- package/types/targets/dom/utils/resolve-elements.d.ts +0 -4
- package/types/targets/dom/utils/stop-animation.d.ts +0 -6
- package/types/targets/dom/utils/time.d.ts +0 -1
- package/types/targets/dom/utils/transforms.d.ts +0 -20
- package/types/targets/js/NumberAnimation.d.ts +0 -24
- package/types/targets/js/easing/cubic-bezier.d.ts +0 -1
- package/types/targets/js/easing/glide/generator.d.ts +0 -5
- package/types/targets/js/easing/glide/index.d.ts +0 -2
- package/types/targets/js/easing/glide/types.d.ts +0 -14
- package/types/targets/js/easing/spring/generator.d.ts +0 -6
- package/types/targets/js/easing/spring/index.d.ts +0 -2
- package/types/targets/js/easing/spring/types.d.ts +0 -10
- package/types/targets/js/easing/steps.d.ts +0 -3
- package/types/targets/js/easing/utils/create-generator-easing.d.ts +0 -3
- package/types/targets/js/easing/utils/get-function.d.ts +0 -3
- package/types/targets/js/easing/utils/has-reached-target.d.ts +0 -1
- package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +0 -7
- package/types/targets/js/types.d.ts +0 -12
- package/types/targets/js/utils/get-easing.d.ts +0 -1
- package/types/targets/js/utils/interpolate.d.ts +0 -2
- package/types/targets/js/utils/offset.d.ts +0 -2
- package/types/targets/react/animated.d.ts +0 -3
- package/types/targets/react/context.d.ts +0 -3
- package/types/targets/react/hooks/use-animation.d.ts +0 -4
- package/types/targets/react/hooks/use-exit.d.ts +0 -3
- package/types/targets/react/hooks/use-gesture-state.d.ts +0 -4
- package/types/targets/react/hooks/use-hover.d.ts +0 -4
- package/types/targets/react/hooks/use-press.d.ts +0 -4
- package/types/targets/react/hooks/use-viewport.d.ts +0 -4
- package/types/targets/react/index.d.ts +0 -2
- package/types/targets/react/types.d.ts +0 -108
- package/types/targets/react/utils/has-changed.d.ts +0 -2
- package/types/targets/react/utils/keyframes.d.ts +0 -3
- package/types/targets/react/utils/poses.d.ts +0 -2
- package/types/targets/react/utils/supported-elements.d.ts +0 -8
- package/types/targets/react/utils/update-target.d.ts +0 -3
- package/types/utils/array.d.ts +0 -2
- package/types/utils/clamp.d.ts +0 -1
- package/types/utils/interpolate.d.ts +0 -0
- package/types/utils/is-number.d.ts +0 -1
- package/types/utils/mix.d.ts +0 -1
- package/types/utils/noop.d.ts +0 -2
- package/types/utils/progress.d.ts +0 -1
- package/types/utils/stagger.d.ts +0 -12
- package/types/utils/value-types.d.ts +0 -0
- package/types/utils/velocity-per-second.d.ts +0 -1
- package/types/utils/wrap.d.ts +0 -1
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { getAnimationData } from './data.es.js';
|
|
2
|
-
import { isCssVar, registerCssVariable } from './utils/css-var.es.js';
|
|
3
|
-
import { noop } from '../../utils/noop.es.js';
|
|
4
|
-
import { ms } from './utils/time.es.js';
|
|
5
|
-
import { isTransform, addTransformToElement, transformDefinitions } from './utils/transforms.es.js';
|
|
6
|
-
import { isCustomEasing, isEasingList, convertEasing } from './utils/easing.es.js';
|
|
7
|
-
import { supports } from './utils/feature-detection.es.js';
|
|
8
|
-
import { cssVariableRenderer, styleRenderer } from './utils/apply.es.js';
|
|
9
|
-
import { NumberAnimation } from '../js/NumberAnimation.es.js';
|
|
10
|
-
import { hydrateKeyframes, keyframesList } from './utils/keyframes.es.js';
|
|
11
|
-
import { style } from './style.es.js';
|
|
12
|
-
import { defaults } from './utils/defaults.es.js';
|
|
13
|
-
import { getStyleName } from './utils/get-style-name.es.js';
|
|
14
|
-
import { isNumber } from '../../utils/is-number.es.js';
|
|
15
|
-
import { stopAnimation } from './utils/stop-animation.es.js';
|
|
16
|
-
|
|
17
|
-
function animateStyle(element, key, keyframesDefinition, options = {}) {
|
|
18
|
-
let animation;
|
|
19
|
-
let { duration = defaults.duration, delay = defaults.delay, endDelay = defaults.endDelay, repeat = defaults.repeat, easing = defaults.easing, direction, offset, allowWebkitAcceleration = false, } = options;
|
|
20
|
-
const data = getAnimationData(element);
|
|
21
|
-
let canAnimateNatively = supports.waapi();
|
|
22
|
-
let render = noop;
|
|
23
|
-
const valueIsTransform = isTransform(key);
|
|
24
|
-
/**
|
|
25
|
-
* If this is an individual transform, we need to map its
|
|
26
|
-
* key to a CSS variable and update the element's transform style
|
|
27
|
-
*/
|
|
28
|
-
valueIsTransform && addTransformToElement(element, key);
|
|
29
|
-
const name = getStyleName(key);
|
|
30
|
-
/**
|
|
31
|
-
* Get definition of value, this will be used to convert numerical
|
|
32
|
-
* keyframes into the default value type.
|
|
33
|
-
*/
|
|
34
|
-
const definition = transformDefinitions.get(name);
|
|
35
|
-
/**
|
|
36
|
-
* Stop the current animation, if any. Because this will trigger
|
|
37
|
-
* commitStyles (DOM writes) and we might later trigger DOM reads,
|
|
38
|
-
* this is fired now and we return a factory function to create
|
|
39
|
-
* the actual animation that can get called in batch,
|
|
40
|
-
*/
|
|
41
|
-
stopAnimation(data.animations[name]);
|
|
42
|
-
/**
|
|
43
|
-
* Batchable factory function containing all DOM reads.
|
|
44
|
-
*/
|
|
45
|
-
return () => {
|
|
46
|
-
const readInitialValue = () => { var _a, _b; return (_b = (_a = style.get(element, name)) !== null && _a !== void 0 ? _a : definition === null || definition === void 0 ? void 0 : definition.initialValue) !== null && _b !== void 0 ? _b : 0; };
|
|
47
|
-
/**
|
|
48
|
-
* Replace null values with the previous keyframe value, or read
|
|
49
|
-
* it from the DOM if it's the first keyframe.
|
|
50
|
-
*/
|
|
51
|
-
let keyframes = hydrateKeyframes(keyframesList(keyframesDefinition), readInitialValue);
|
|
52
|
-
if (isCustomEasing(easing)) {
|
|
53
|
-
const custom = easing.createAnimation(keyframes, readInitialValue, valueIsTransform, name, data);
|
|
54
|
-
easing = custom.easing;
|
|
55
|
-
if (custom.keyframes !== undefined)
|
|
56
|
-
keyframes = custom.keyframes;
|
|
57
|
-
if (custom.duration !== undefined)
|
|
58
|
-
duration = custom.duration;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* If this is a CSS variable we need to register it with the browser
|
|
62
|
-
* before it can be animated natively. We also set it with setProperty
|
|
63
|
-
* rather than directly onto the element.style object.
|
|
64
|
-
*/
|
|
65
|
-
if (isCssVar(name)) {
|
|
66
|
-
render = cssVariableRenderer(element, name);
|
|
67
|
-
if (supports.cssRegisterProperty()) {
|
|
68
|
-
registerCssVariable(name);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
canAnimateNatively = false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
render = styleRenderer(element, name);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* If we can animate this value with WAAPI, do so. Currently this only
|
|
79
|
-
* feature detects CSS.registerProperty but could check WAAPI too.
|
|
80
|
-
*/
|
|
81
|
-
if (canAnimateNatively) {
|
|
82
|
-
/**
|
|
83
|
-
* Convert numbers to default value types. Currently this only supports
|
|
84
|
-
* transforms but it could also support other value types.
|
|
85
|
-
*/
|
|
86
|
-
if (definition) {
|
|
87
|
-
keyframes = keyframes.map((value) => isNumber(value) ? definition.toDefaultUnit(value) : value);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* If this browser doesn't support partial/implicit keyframes we need to
|
|
91
|
-
* explicitly provide one.
|
|
92
|
-
*/
|
|
93
|
-
if (!supports.partialKeyframes() && keyframes.length === 1) {
|
|
94
|
-
keyframes.unshift(readInitialValue());
|
|
95
|
-
}
|
|
96
|
-
const animationOptions = {
|
|
97
|
-
delay: ms(delay),
|
|
98
|
-
duration: ms(duration),
|
|
99
|
-
endDelay: ms(endDelay),
|
|
100
|
-
easing: !isEasingList(easing) ? convertEasing(easing) : undefined,
|
|
101
|
-
direction,
|
|
102
|
-
iterations: repeat + 1,
|
|
103
|
-
fill: "both",
|
|
104
|
-
};
|
|
105
|
-
animation = element.animate({
|
|
106
|
-
[name]: keyframes,
|
|
107
|
-
offset,
|
|
108
|
-
easing: isEasingList(easing) ? easing.map(convertEasing) : undefined,
|
|
109
|
-
}, animationOptions);
|
|
110
|
-
/**
|
|
111
|
-
* Polyfill finished Promise in browsers that don't support it
|
|
112
|
-
*/
|
|
113
|
-
if (!animation.finished) {
|
|
114
|
-
animation.finished = new Promise((resolve, reject) => {
|
|
115
|
-
animation.onfinish = resolve;
|
|
116
|
-
animation.oncancel = reject;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
const target = keyframes[keyframes.length - 1];
|
|
120
|
-
animation.finished
|
|
121
|
-
.then(() => {
|
|
122
|
-
// Apply styles to target
|
|
123
|
-
render(target);
|
|
124
|
-
// Ensure fill modes don't persist
|
|
125
|
-
animation.cancel();
|
|
126
|
-
})
|
|
127
|
-
.catch(noop);
|
|
128
|
-
/**
|
|
129
|
-
* This forces Webkit to run animations on the main thread by exploiting
|
|
130
|
-
* this condition:
|
|
131
|
-
* https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp?rev=281238#L1099
|
|
132
|
-
*
|
|
133
|
-
* This fixes Webkit's timing bugs, like accelerated animations falling
|
|
134
|
-
* out of sync with main thread animations and massive delays in starting
|
|
135
|
-
* accelerated animations in WKWebView.
|
|
136
|
-
*/
|
|
137
|
-
if (!allowWebkitAcceleration)
|
|
138
|
-
animation.playbackRate = 1.000001;
|
|
139
|
-
/**
|
|
140
|
-
* If we can't animate the value natively then we can fallback to the numbers-only
|
|
141
|
-
* polyfill for transforms. All keyframes must be numerical.
|
|
142
|
-
*/
|
|
143
|
-
}
|
|
144
|
-
else if (valueIsTransform && keyframes.every(isNumber)) {
|
|
145
|
-
/**
|
|
146
|
-
* If we only have a single keyframe, we need to create an initial keyframe by reading
|
|
147
|
-
* the current value from the DOM.
|
|
148
|
-
*/
|
|
149
|
-
if (keyframes.length === 1) {
|
|
150
|
-
keyframes.unshift(parseFloat(readInitialValue()));
|
|
151
|
-
}
|
|
152
|
-
if (definition) {
|
|
153
|
-
const applyStyle = render;
|
|
154
|
-
render = (v) => applyStyle(definition.toDefaultUnit(v));
|
|
155
|
-
}
|
|
156
|
-
animation = new NumberAnimation(render, keyframes, Object.assign(Object.assign({}, options), { duration,
|
|
157
|
-
easing }));
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
const target = keyframes[keyframes.length - 1];
|
|
161
|
-
render(definition && isNumber(target)
|
|
162
|
-
? definition.toDefaultUnit(target)
|
|
163
|
-
: target);
|
|
164
|
-
}
|
|
165
|
-
data.animations[name] = animation;
|
|
166
|
-
/**
|
|
167
|
-
* When an animation finishes, delete the reference to the previous animation.
|
|
168
|
-
*/
|
|
169
|
-
animation === null || animation === void 0 ? void 0 : animation.finished.then(() => {
|
|
170
|
-
data.animations[name] = undefined;
|
|
171
|
-
data.generators[name] = undefined;
|
|
172
|
-
data.prevGeneratorState[name] = undefined;
|
|
173
|
-
}).catch(noop);
|
|
174
|
-
return animation;
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export { animateStyle };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var animateStyle = require('./animate-style.cjs.js');
|
|
6
|
-
var options = require('./utils/options.cjs.js');
|
|
7
|
-
var resolveElements = require('./utils/resolve-elements.cjs.js');
|
|
8
|
-
var controls = require('./utils/controls.cjs.js');
|
|
9
|
-
var stagger = require('../../utils/stagger.cjs.js');
|
|
10
|
-
var defaults = require('./utils/defaults.cjs.js');
|
|
11
|
-
|
|
12
|
-
function animate(elements, keyframes, options$1 = {}) {
|
|
13
|
-
var _a;
|
|
14
|
-
elements = resolveElements.resolveElements(elements);
|
|
15
|
-
const numElements = elements.length;
|
|
16
|
-
/**
|
|
17
|
-
* Create and start new animations
|
|
18
|
-
*/
|
|
19
|
-
const animationFactories = [];
|
|
20
|
-
for (let i = 0; i < numElements; i++) {
|
|
21
|
-
const element = elements[i];
|
|
22
|
-
for (const key in keyframes) {
|
|
23
|
-
const valueOptions = options.getOptions(options$1, key);
|
|
24
|
-
valueOptions.delay = stagger.resolveOption(valueOptions.delay, i, numElements);
|
|
25
|
-
const animation = animateStyle.animateStyle(element, key, keyframes[key], valueOptions);
|
|
26
|
-
animationFactories.push(animation);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return controls.createAnimations(animationFactories,
|
|
30
|
-
/**
|
|
31
|
-
* TODO:
|
|
32
|
-
* If easing is set to spring or glide, duration will be dynamically
|
|
33
|
-
* generated. Ideally we would dynamically generate this from
|
|
34
|
-
* animation.effect.getComputedTiming().duration but this isn't
|
|
35
|
-
* supported in iOS13 or our number polyfill. Perhaps it's possible
|
|
36
|
-
* to Proxy animations returned from animateStyle that has duration
|
|
37
|
-
* as a getter.
|
|
38
|
-
*/
|
|
39
|
-
(_a = options$1.duration) !== null && _a !== void 0 ? _a : defaults.defaults.duration);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.animate = animate;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { animateStyle } from './animate-style.es.js';
|
|
2
|
-
import { getOptions } from './utils/options.es.js';
|
|
3
|
-
import { resolveElements } from './utils/resolve-elements.es.js';
|
|
4
|
-
import { createAnimations } from './utils/controls.es.js';
|
|
5
|
-
import { resolveOption } from '../../utils/stagger.es.js';
|
|
6
|
-
import { defaults } from './utils/defaults.es.js';
|
|
7
|
-
|
|
8
|
-
function animate(elements, keyframes, options = {}) {
|
|
9
|
-
var _a;
|
|
10
|
-
elements = resolveElements(elements);
|
|
11
|
-
const numElements = elements.length;
|
|
12
|
-
/**
|
|
13
|
-
* Create and start new animations
|
|
14
|
-
*/
|
|
15
|
-
const animationFactories = [];
|
|
16
|
-
for (let i = 0; i < numElements; i++) {
|
|
17
|
-
const element = elements[i];
|
|
18
|
-
for (const key in keyframes) {
|
|
19
|
-
const valueOptions = getOptions(options, key);
|
|
20
|
-
valueOptions.delay = resolveOption(valueOptions.delay, i, numElements);
|
|
21
|
-
const animation = animateStyle(element, key, keyframes[key], valueOptions);
|
|
22
|
-
animationFactories.push(animation);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
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);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { animate };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const data = new WeakMap();
|
|
6
|
-
function getAnimationData(element) {
|
|
7
|
-
if (!data.has(element)) {
|
|
8
|
-
data.set(element, {
|
|
9
|
-
transforms: [],
|
|
10
|
-
animations: {},
|
|
11
|
-
generators: {},
|
|
12
|
-
prevGeneratorState: {},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return data.get(element);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
exports.getAnimationData = getAnimationData;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const data = new WeakMap();
|
|
2
|
-
function getAnimationData(element) {
|
|
3
|
-
if (!data.has(element)) {
|
|
4
|
-
data.set(element, {
|
|
5
|
-
transforms: [],
|
|
6
|
-
animations: {},
|
|
7
|
-
generators: {},
|
|
8
|
-
prevGeneratorState: {},
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
return data.get(element);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { getAnimationData };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var cssVar = require('./utils/css-var.cjs.js');
|
|
6
|
-
var transforms = require('./utils/transforms.cjs.js');
|
|
7
|
-
|
|
8
|
-
const style = {
|
|
9
|
-
get: (element, name) => {
|
|
10
|
-
let value = cssVar.isCssVar(name)
|
|
11
|
-
? element.style.getPropertyValue(name)
|
|
12
|
-
: getComputedStyle(element)[name];
|
|
13
|
-
if (!value && value !== 0) {
|
|
14
|
-
const definition = transforms.transformDefinitions.get(name);
|
|
15
|
-
if (definition)
|
|
16
|
-
value = definition.initialValue;
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
exports.style = style;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { isCssVar } from './utils/css-var.es.js';
|
|
2
|
-
import { transformDefinitions } from './utils/transforms.es.js';
|
|
3
|
-
|
|
4
|
-
const style = {
|
|
5
|
-
get: (element, name) => {
|
|
6
|
-
let value = isCssVar(name)
|
|
7
|
-
? element.style.getPropertyValue(name)
|
|
8
|
-
: getComputedStyle(element)[name];
|
|
9
|
-
if (!value && value !== 0) {
|
|
10
|
-
const definition = transformDefinitions.get(name);
|
|
11
|
-
if (definition)
|
|
12
|
-
value = definition.initialValue;
|
|
13
|
-
}
|
|
14
|
-
return value;
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { style };
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var progress = require('../../../utils/progress.cjs.js');
|
|
7
|
-
var stagger = require('../../../utils/stagger.cjs.js');
|
|
8
|
-
var offset = require('../../js/utils/offset.cjs.js');
|
|
9
|
-
var animateStyle = require('../animate-style.cjs.js');
|
|
10
|
-
var controls = require('../utils/controls.cjs.js');
|
|
11
|
-
var defaults = require('../utils/defaults.cjs.js');
|
|
12
|
-
var keyframes = require('../utils/keyframes.cjs.js');
|
|
13
|
-
var options = require('../utils/options.cjs.js');
|
|
14
|
-
var resolveElements = require('../utils/resolve-elements.cjs.js');
|
|
15
|
-
var calcTime = require('./utils/calc-time.cjs.js');
|
|
16
|
-
var edit = require('./utils/edit.cjs.js');
|
|
17
|
-
var sort = require('./utils/sort.cjs.js');
|
|
18
|
-
|
|
19
|
-
function timeline(definition, options = {}) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const animationDefinitions = createAnimationsFromTimeline(definition, options);
|
|
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,
|
|
29
|
-
// Get the duration from the first animation definition
|
|
30
|
-
(_b = (_a = animationDefinitions[0]) === null || _a === void 0 ? void 0 : _a[3].duration) !== null && _b !== void 0 ? _b : defaults.defaults.duration);
|
|
31
|
-
}
|
|
32
|
-
function createAnimationsFromTimeline(definition, _a = {}) {
|
|
33
|
-
var { defaultOptions = {} } = _a, timelineOptions = tslib.__rest(_a, ["defaultOptions"]);
|
|
34
|
-
const animationDefinitions = [];
|
|
35
|
-
const elementSequences = new Map();
|
|
36
|
-
const elementCache = {};
|
|
37
|
-
const timeLabels = new Map();
|
|
38
|
-
let prevTime = 0;
|
|
39
|
-
let currentTime = 0;
|
|
40
|
-
let totalDuration = 0;
|
|
41
|
-
/**
|
|
42
|
-
* Build the timeline by mapping over the definition array and converting
|
|
43
|
-
* the definitions into keyframes and offsets with absolute time values.
|
|
44
|
-
* These will later get converted into relative offsets in a second pass.
|
|
45
|
-
*/
|
|
46
|
-
for (let i = 0; i < definition.length; i++) {
|
|
47
|
-
const [elementDefinition, keyframes$1, options$1 = {}] = definition[i];
|
|
48
|
-
/**
|
|
49
|
-
* If a relative or absolute time value has been specified we need to resolve
|
|
50
|
-
* it in relation to the currentTime.
|
|
51
|
-
*/
|
|
52
|
-
if (options$1.at !== undefined) {
|
|
53
|
-
currentTime = calcTime.calcNextTime(currentTime, options$1.at, prevTime, timeLabels);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Keep track of the maximum duration in this definition. This will be
|
|
57
|
-
* applied to currentTime once the definition has been parsed.
|
|
58
|
-
*/
|
|
59
|
-
let maxDuration = 0;
|
|
60
|
-
/**
|
|
61
|
-
* Find all the elements specified in the definition and parse value
|
|
62
|
-
* keyframes from their timeline definitions.
|
|
63
|
-
*/
|
|
64
|
-
const elements = resolveElements.resolveElements(elementDefinition, elementCache);
|
|
65
|
-
const numElements = elements.length;
|
|
66
|
-
for (let elementIndex = 0; elementIndex < numElements; elementIndex++) {
|
|
67
|
-
const element = elements[elementIndex];
|
|
68
|
-
const elementSequence = getElementSequence(element, elementSequences);
|
|
69
|
-
for (const key in keyframes$1) {
|
|
70
|
-
const valueSequence = getValueSequence(key, elementSequence);
|
|
71
|
-
const valueKeyframes = keyframes.keyframesList(keyframes$1[key]);
|
|
72
|
-
const valueOptions = options.getOptions(options$1, key);
|
|
73
|
-
let { duration = defaultOptions.duration || defaults.defaults.duration, easing = defaultOptions.easing || defaults.defaults.easing, } = valueOptions;
|
|
74
|
-
const delay = stagger.resolveOption(options$1.delay, elementIndex, numElements) || 0;
|
|
75
|
-
const startTime = currentTime + delay;
|
|
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
|
-
*/
|
|
86
|
-
if (offset$1.length === 1 && offset$1[0] === 0) {
|
|
87
|
-
offset$1[1] = 1;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Fill out if offset if fewer offsets than keyframes
|
|
91
|
-
*/
|
|
92
|
-
const remainder = length - valueKeyframes.length;
|
|
93
|
-
remainder > 0 && offset.fillOffset(offset$1, remainder);
|
|
94
|
-
/**
|
|
95
|
-
* If only one value has been set, ie [1], push a null to the start of
|
|
96
|
-
* the keyframe array. This will let us mark a keyframe at this point
|
|
97
|
-
* that will later be hydrated with the previous value.
|
|
98
|
-
*/
|
|
99
|
-
valueKeyframes.length === 1 && valueKeyframes.unshift(null);
|
|
100
|
-
/**
|
|
101
|
-
* Add keyframes, mapping offsets to absolute time.
|
|
102
|
-
*/
|
|
103
|
-
edit.addKeyframes(valueSequence, valueKeyframes, easing, offset$1, startTime, targetTime);
|
|
104
|
-
maxDuration = Math.max(delay + duration, maxDuration);
|
|
105
|
-
totalDuration = Math.max(targetTime, totalDuration);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
prevTime = currentTime;
|
|
109
|
-
currentTime += maxDuration;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* For every element and value combination create a new animation.
|
|
113
|
-
*/
|
|
114
|
-
elementSequences.forEach((valueSequences, element) => {
|
|
115
|
-
for (const key in valueSequences) {
|
|
116
|
-
const valueSequence = valueSequences[key];
|
|
117
|
-
/**
|
|
118
|
-
* Arrange all the keyframes in ascending time order.
|
|
119
|
-
*/
|
|
120
|
-
valueSequence.sort(sort.compareByTime);
|
|
121
|
-
const keyframes = [];
|
|
122
|
-
const valueOffset = [];
|
|
123
|
-
const valueEasing = [];
|
|
124
|
-
/**
|
|
125
|
-
* For each keyframe, translate absolute times into
|
|
126
|
-
* relative offsets based on the total duration of the timeline.
|
|
127
|
-
*/
|
|
128
|
-
for (let i = 0; i < valueSequence.length; i++) {
|
|
129
|
-
const { at, value, easing } = valueSequence[i];
|
|
130
|
-
keyframes.push(value);
|
|
131
|
-
valueOffset.push(progress.progress(0, totalDuration, at));
|
|
132
|
-
valueEasing.push(easing || defaults.defaults.easing);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* If the first keyframe doesn't land on offset: 0
|
|
136
|
-
* provide one by duplicating the initial keyframe. This ensures
|
|
137
|
-
* it snaps to the first keyframe when the animation starts.
|
|
138
|
-
*/
|
|
139
|
-
if (valueOffset[0] !== 0) {
|
|
140
|
-
valueOffset.unshift(0);
|
|
141
|
-
keyframes.unshift(keyframes[0]);
|
|
142
|
-
valueEasing.unshift("linear");
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* If the last keyframe doesn't land on offset: 1
|
|
146
|
-
* provide one with a null wildcard value. This will ensure it
|
|
147
|
-
* stays static until the end of the animation.
|
|
148
|
-
*/
|
|
149
|
-
if (valueOffset[valueOffset.length - 1] !== 1) {
|
|
150
|
-
valueOffset.push(1);
|
|
151
|
-
keyframes.push(null);
|
|
152
|
-
}
|
|
153
|
-
animationDefinitions.push([
|
|
154
|
-
element,
|
|
155
|
-
key,
|
|
156
|
-
keyframes,
|
|
157
|
-
Object.assign(Object.assign(Object.assign({}, defaultOptions), { duration: totalDuration, easing: valueEasing, offset: valueOffset }), timelineOptions),
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return animationDefinitions;
|
|
162
|
-
}
|
|
163
|
-
function getElementSequence(element, sequences) {
|
|
164
|
-
!sequences.has(element) && sequences.set(element, {});
|
|
165
|
-
return sequences.get(element);
|
|
166
|
-
}
|
|
167
|
-
function getValueSequence(name, sequences) {
|
|
168
|
-
if (!sequences[name])
|
|
169
|
-
sequences[name] = [];
|
|
170
|
-
return sequences[name];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
exports.createAnimationsFromTimeline = createAnimationsFromTimeline;
|
|
174
|
-
exports.timeline = timeline;
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
|
-
import { progress } from '../../../utils/progress.es.js';
|
|
3
|
-
import { resolveOption } from '../../../utils/stagger.es.js';
|
|
4
|
-
import { defaultOffset, fillOffset } from '../../js/utils/offset.es.js';
|
|
5
|
-
import { animateStyle } from '../animate-style.es.js';
|
|
6
|
-
import { createAnimations } from '../utils/controls.es.js';
|
|
7
|
-
import { defaults } from '../utils/defaults.es.js';
|
|
8
|
-
import { keyframesList } from '../utils/keyframes.es.js';
|
|
9
|
-
import { getOptions } from '../utils/options.es.js';
|
|
10
|
-
import { resolveElements } from '../utils/resolve-elements.es.js';
|
|
11
|
-
import { calcNextTime } from './utils/calc-time.es.js';
|
|
12
|
-
import { addKeyframes } from './utils/edit.es.js';
|
|
13
|
-
import { compareByTime } from './utils/sort.es.js';
|
|
14
|
-
|
|
15
|
-
function timeline(definition, options = {}) {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
const animationDefinitions = createAnimationsFromTimeline(definition, options);
|
|
18
|
-
/**
|
|
19
|
-
* Create and start animations
|
|
20
|
-
*/
|
|
21
|
-
const animationFactories = animationDefinitions
|
|
22
|
-
.map((definition) => animateStyle(...definition))
|
|
23
|
-
.filter(Boolean);
|
|
24
|
-
return createAnimations(animationFactories,
|
|
25
|
-
// Get the duration from the first animation definition
|
|
26
|
-
(_b = (_a = animationDefinitions[0]) === null || _a === void 0 ? void 0 : _a[3].duration) !== null && _b !== void 0 ? _b : defaults.duration);
|
|
27
|
-
}
|
|
28
|
-
function createAnimationsFromTimeline(definition, _a = {}) {
|
|
29
|
-
var { defaultOptions = {} } = _a, timelineOptions = __rest(_a, ["defaultOptions"]);
|
|
30
|
-
const animationDefinitions = [];
|
|
31
|
-
const elementSequences = new Map();
|
|
32
|
-
const elementCache = {};
|
|
33
|
-
const timeLabels = new Map();
|
|
34
|
-
let prevTime = 0;
|
|
35
|
-
let currentTime = 0;
|
|
36
|
-
let totalDuration = 0;
|
|
37
|
-
/**
|
|
38
|
-
* Build the timeline by mapping over the definition array and converting
|
|
39
|
-
* the definitions into keyframes and offsets with absolute time values.
|
|
40
|
-
* These will later get converted into relative offsets in a second pass.
|
|
41
|
-
*/
|
|
42
|
-
for (let i = 0; i < definition.length; i++) {
|
|
43
|
-
const [elementDefinition, keyframes, options = {}] = definition[i];
|
|
44
|
-
/**
|
|
45
|
-
* If a relative or absolute time value has been specified we need to resolve
|
|
46
|
-
* it in relation to the currentTime.
|
|
47
|
-
*/
|
|
48
|
-
if (options.at !== undefined) {
|
|
49
|
-
currentTime = calcNextTime(currentTime, options.at, prevTime, timeLabels);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Keep track of the maximum duration in this definition. This will be
|
|
53
|
-
* applied to currentTime once the definition has been parsed.
|
|
54
|
-
*/
|
|
55
|
-
let maxDuration = 0;
|
|
56
|
-
/**
|
|
57
|
-
* Find all the elements specified in the definition and parse value
|
|
58
|
-
* keyframes from their timeline definitions.
|
|
59
|
-
*/
|
|
60
|
-
const elements = resolveElements(elementDefinition, elementCache);
|
|
61
|
-
const numElements = elements.length;
|
|
62
|
-
for (let elementIndex = 0; elementIndex < numElements; elementIndex++) {
|
|
63
|
-
const element = elements[elementIndex];
|
|
64
|
-
const elementSequence = getElementSequence(element, elementSequences);
|
|
65
|
-
for (const key in keyframes) {
|
|
66
|
-
const valueSequence = getValueSequence(key, elementSequence);
|
|
67
|
-
const valueKeyframes = keyframesList(keyframes[key]);
|
|
68
|
-
const valueOptions = getOptions(options, key);
|
|
69
|
-
let { duration = defaultOptions.duration || defaults.duration, easing = defaultOptions.easing || defaults.easing, } = valueOptions;
|
|
70
|
-
const delay = resolveOption(options.delay, elementIndex, numElements) || 0;
|
|
71
|
-
const startTime = currentTime + delay;
|
|
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
|
-
*/
|
|
82
|
-
if (offset.length === 1 && offset[0] === 0) {
|
|
83
|
-
offset[1] = 1;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Fill out if offset if fewer offsets than keyframes
|
|
87
|
-
*/
|
|
88
|
-
const remainder = length - valueKeyframes.length;
|
|
89
|
-
remainder > 0 && fillOffset(offset, remainder);
|
|
90
|
-
/**
|
|
91
|
-
* If only one value has been set, ie [1], push a null to the start of
|
|
92
|
-
* the keyframe array. This will let us mark a keyframe at this point
|
|
93
|
-
* that will later be hydrated with the previous value.
|
|
94
|
-
*/
|
|
95
|
-
valueKeyframes.length === 1 && valueKeyframes.unshift(null);
|
|
96
|
-
/**
|
|
97
|
-
* Add keyframes, mapping offsets to absolute time.
|
|
98
|
-
*/
|
|
99
|
-
addKeyframes(valueSequence, valueKeyframes, easing, offset, startTime, targetTime);
|
|
100
|
-
maxDuration = Math.max(delay + duration, maxDuration);
|
|
101
|
-
totalDuration = Math.max(targetTime, totalDuration);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
prevTime = currentTime;
|
|
105
|
-
currentTime += maxDuration;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* For every element and value combination create a new animation.
|
|
109
|
-
*/
|
|
110
|
-
elementSequences.forEach((valueSequences, element) => {
|
|
111
|
-
for (const key in valueSequences) {
|
|
112
|
-
const valueSequence = valueSequences[key];
|
|
113
|
-
/**
|
|
114
|
-
* Arrange all the keyframes in ascending time order.
|
|
115
|
-
*/
|
|
116
|
-
valueSequence.sort(compareByTime);
|
|
117
|
-
const keyframes = [];
|
|
118
|
-
const valueOffset = [];
|
|
119
|
-
const valueEasing = [];
|
|
120
|
-
/**
|
|
121
|
-
* For each keyframe, translate absolute times into
|
|
122
|
-
* relative offsets based on the total duration of the timeline.
|
|
123
|
-
*/
|
|
124
|
-
for (let i = 0; i < valueSequence.length; i++) {
|
|
125
|
-
const { at, value, easing } = valueSequence[i];
|
|
126
|
-
keyframes.push(value);
|
|
127
|
-
valueOffset.push(progress(0, totalDuration, at));
|
|
128
|
-
valueEasing.push(easing || defaults.easing);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* If the first keyframe doesn't land on offset: 0
|
|
132
|
-
* provide one by duplicating the initial keyframe. This ensures
|
|
133
|
-
* it snaps to the first keyframe when the animation starts.
|
|
134
|
-
*/
|
|
135
|
-
if (valueOffset[0] !== 0) {
|
|
136
|
-
valueOffset.unshift(0);
|
|
137
|
-
keyframes.unshift(keyframes[0]);
|
|
138
|
-
valueEasing.unshift("linear");
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* If the last keyframe doesn't land on offset: 1
|
|
142
|
-
* provide one with a null wildcard value. This will ensure it
|
|
143
|
-
* stays static until the end of the animation.
|
|
144
|
-
*/
|
|
145
|
-
if (valueOffset[valueOffset.length - 1] !== 1) {
|
|
146
|
-
valueOffset.push(1);
|
|
147
|
-
keyframes.push(null);
|
|
148
|
-
}
|
|
149
|
-
animationDefinitions.push([
|
|
150
|
-
element,
|
|
151
|
-
key,
|
|
152
|
-
keyframes,
|
|
153
|
-
Object.assign(Object.assign(Object.assign({}, defaultOptions), { duration: totalDuration, easing: valueEasing, offset: valueOffset }), timelineOptions),
|
|
154
|
-
]);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
return animationDefinitions;
|
|
158
|
-
}
|
|
159
|
-
function getElementSequence(element, sequences) {
|
|
160
|
-
!sequences.has(element) && sequences.set(element, {});
|
|
161
|
-
return sequences.get(element);
|
|
162
|
-
}
|
|
163
|
-
function getValueSequence(name, sequences) {
|
|
164
|
-
if (!sequences[name])
|
|
165
|
-
sequences[name] = [];
|
|
166
|
-
return sequences[name];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export { createAnimationsFromTimeline, timeline };
|