motion 12.0.0-alpha.2 → 12.0.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/LICENSE.md +1 -1
- package/README.md +7 -24
- package/dist/cjs/index.js +2792 -2446
- package/dist/cjs/mini.js +629 -193
- package/dist/cjs/react-client.js +3624 -3434
- package/dist/cjs/react-m.js +397 -351
- package/dist/cjs/react-mini.js +225 -191
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +3 -2
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +16 -12
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +3 -2
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +10 -10
- package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +30 -89
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +4 -4
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +14 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/generators/spring/defaults.mjs +27 -0
- package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +10 -13
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +57 -18
- package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +7 -6
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +6 -5
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +32 -6
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-repeat-duration.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/normalize-times.mjs +13 -0
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +10 -7
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +6 -3
- package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +2 -1
- package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +6 -6
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +5 -4
- package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +2 -1
- package/dist/es/framer-motion/dist/es/frameloop/render-step.mjs +3 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +12 -15
- package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +20 -22
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +6 -5
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +20 -119
- package/dist/es/framer-motion/dist/es/motion/index.mjs +11 -7
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +3 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +11 -5
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -2
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +15 -14
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +15 -13
- package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +4 -3
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +4 -4
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +6 -5
- package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +2 -14
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +4 -3
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +6 -20
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +2 -2
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/html/utils/keys-position.mjs +13 -0
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +6 -6
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +57 -24
- package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +8 -5
- package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +3 -3
- package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +1 -1
- package/dist/es/motion/lib/index.mjs +12 -7
- package/dist/es/motion/lib/mini.mjs +1 -0
- package/dist/es/motion/lib/react.mjs +41 -37
- package/dist/es/{framer-motion/dist/es/animation/GroupPlaybackControls.mjs → motion-dom/dist/es/animation/controls/BaseGroup.mjs} +7 -6
- package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +13 -0
- package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es/animation/generators}/utils/create-generator-easing.mjs +6 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +85 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi → motion-dom/dist/es/animation/waapi/utils}/easing.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/linear.mjs +4 -4
- package/dist/es/motion-dom/dist/es/gestures/drag/state/is-active.mjs +9 -0
- package/dist/es/motion-dom/dist/es/gestures/drag/state/set-active.mjs +28 -0
- package/dist/es/motion-dom/dist/es/gestures/hover.mjs +37 -0
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +76 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +38 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/state.mjs +3 -0
- package/dist/es/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +22 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs → motion-dom/dist/es/utils/supports/linear-easing.mjs} +1 -1
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs → motion-dom/dist/es/utils/supports/memo.mjs} +3 -2
- package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/memo.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/noop.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/progress.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/time-conversion.mjs +2 -0
- package/dist/motion.dev.js +2792 -2446
- package/dist/motion.js +1 -1
- package/package.json +6 -6
- package/.turbo/turbo-build.log +0 -47
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +0 -53
- package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
- package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +0 -28
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/mini.js +0 -2
- package/lib/mini.js.map +0 -1
- package/lib/react-client.js +0 -3
- package/lib/react-client.js.map +0 -1
- package/lib/react-m.js +0 -3
- package/lib/react-m.js.map +0 -1
- package/lib/react-mini.js +0 -3
- package/lib/react-mini.js.map +0 -1
- package/lib/react.js +0 -3
- package/lib/react.js.map +0 -1
- package/rollup.config.mjs +0 -210
- package/src/index.ts +0 -1
- package/src/mini.ts +0 -1
- package/src/react-client.ts +0 -3
- package/src/react-m.ts +0 -3
- package/src/react-mini.ts +0 -3
- package/src/react.ts +0 -3
- package/tsconfig.json +0 -25
- package/types/index.d.ts +0 -1
- package/types/mini.d.ts +0 -1
- package/types/react-client.d.ts +0 -1
- package/types/react-m.d.ts +0 -1
- package/types/react-mini.d.ts +0 -1
- package/types/react.d.ts +0 -1
- /package/dist/es/framer-motion/dist/es/render/html/utils/{transform.mjs → keys-transform.mjs} +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/calc-duration.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/is-generator.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/get-value-transition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/attach-timeline.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/gestures/utils/is-node-or-child.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/events → motion-dom/dist/es/gestures}/utils/is-primary-pointer.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es}/utils/is-bezier-definition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs → motion-dom/dist/es/utils/supports/flags.mjs} +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/errors.mjs +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { calcGeneratorDuration } from '../../../../../motion-dom/dist/es/animation/generators/utils/calc-duration.mjs';
|
|
4
|
+
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
1
5
|
import { KeyframeResolver } from '../../render/utils/KeyframesResolver.mjs';
|
|
2
|
-
import {
|
|
6
|
+
import { clamp } from '../../utils/clamp.mjs';
|
|
7
|
+
import { mix } from '../../utils/mix/index.mjs';
|
|
8
|
+
import { pipe } from '../../utils/pipe.mjs';
|
|
3
9
|
import { inertia } from '../generators/inertia.mjs';
|
|
4
10
|
import { keyframes } from '../generators/keyframes.mjs';
|
|
11
|
+
import { spring } from '../generators/spring/index.mjs';
|
|
5
12
|
import { BaseAnimation } from './BaseAnimation.mjs';
|
|
6
|
-
import { pipe } from '../../utils/pipe.mjs';
|
|
7
|
-
import { mix } from '../../utils/mix/index.mjs';
|
|
8
|
-
import { calcGeneratorDuration } from '../generators/utils/calc-duration.mjs';
|
|
9
|
-
import { millisecondsToSeconds, secondsToMilliseconds } from '../../utils/time-conversion.mjs';
|
|
10
|
-
import { clamp } from '../../utils/clamp.mjs';
|
|
11
|
-
import { invariant } from '../../utils/errors.mjs';
|
|
12
13
|
import { frameloopDriver } from './drivers/driver-frameloop.mjs';
|
|
13
14
|
import { getFinalKeyframe } from './waapi/utils/get-final-keyframe.mjs';
|
|
14
|
-
import { isGenerator } from '../generators/utils/is-generator.mjs';
|
|
15
15
|
|
|
16
16
|
const generators = {
|
|
17
17
|
decay: inertia,
|
|
@@ -61,13 +61,13 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
61
61
|
* animation.stop is returned as a reference from a useEffect.
|
|
62
62
|
*/
|
|
63
63
|
this.stop = () => {
|
|
64
|
-
const { onStop } = this.options;
|
|
65
|
-
onStop && onStop();
|
|
66
64
|
this.resolver.cancel();
|
|
67
65
|
this.isStopped = true;
|
|
68
66
|
if (this.state === "idle")
|
|
69
67
|
return;
|
|
70
68
|
this.teardown();
|
|
69
|
+
const { onStop } = this.options;
|
|
70
|
+
onStop && onStop();
|
|
71
71
|
};
|
|
72
72
|
const { name, motionValue, element, keyframes } = this.options;
|
|
73
73
|
const KeyframeResolver$1 = (element === null || element === void 0 ? void 0 : element.KeyframeResolver) || KeyframeResolver;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { warning } from '
|
|
2
|
-
import { isGenerator } from '
|
|
1
|
+
import { warning } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { isGenerator } from '../../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
3
3
|
import { isAnimatable } from '../../utils/is-animatable.mjs';
|
|
4
4
|
|
|
5
5
|
function hasKeyframesChanged(keyframes) {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import { invariant } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { createGeneratorEasing } from '../../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
|
|
4
|
+
import { isGenerator } from '../../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
5
|
+
import { NativeAnimationControls } from '../../../../../../motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs';
|
|
6
|
+
import { supportsLinearEasing } from '../../../../../../motion-dom/dist/es/utils/supports/linear-easing.mjs';
|
|
1
7
|
import { startWaapiAnimation } from './index.mjs';
|
|
2
|
-
import { createGeneratorEasing } from '../../../easing/utils/create-generator-easing.mjs';
|
|
3
8
|
import { browserNumberValueTypes } from '../../../render/dom/value-types/number-browser.mjs';
|
|
4
|
-
import { invariant } from '../../../utils/errors.mjs';
|
|
5
|
-
import { noop } from '../../../utils/noop.mjs';
|
|
6
|
-
import { secondsToMilliseconds, millisecondsToSeconds } from '../../../utils/time-conversion.mjs';
|
|
7
|
-
import { isGenerator } from '../../generators/utils/is-generator.mjs';
|
|
8
|
-
import { attachTimeline } from './utils/attach-timeline.mjs';
|
|
9
9
|
import { getFinalKeyframe } from './utils/get-final-keyframe.mjs';
|
|
10
10
|
import { setCSSVar, setStyle } from './utils/style.mjs';
|
|
11
|
-
import { supportsLinearEasing } from './utils/supports-linear-easing.mjs';
|
|
12
11
|
import { supportsPartialKeyframes } from './utils/supports-partial-keyframes.mjs';
|
|
13
12
|
import { supportsWaapi } from './utils/supports-waapi.mjs';
|
|
14
13
|
|
|
@@ -33,12 +32,9 @@ function getElementAnimationState(element) {
|
|
|
33
32
|
state.set(element, animationState);
|
|
34
33
|
return state.get(element);
|
|
35
34
|
}
|
|
36
|
-
class NativeAnimation {
|
|
35
|
+
class NativeAnimation extends NativeAnimationControls {
|
|
37
36
|
constructor(element, valueName, valueKeyframes, options) {
|
|
38
37
|
const isCSSVar = valueName.startsWith("--");
|
|
39
|
-
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
40
|
-
this.options = options;
|
|
41
|
-
this.updateFinishedPromise();
|
|
42
38
|
invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
43
39
|
const existingAnimation = getElementAnimationState(element).get(valueName);
|
|
44
40
|
existingAnimation && existingAnimation.stop();
|
|
@@ -51,6 +47,7 @@ class NativeAnimation {
|
|
|
51
47
|
valueKeyframes = [valueKeyframes];
|
|
52
48
|
}
|
|
53
49
|
hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
|
|
50
|
+
// TODO: Replace this with toString()?
|
|
54
51
|
if (isGenerator(options.type)) {
|
|
55
52
|
const generatorOptions = createGeneratorEasing(options, 100, options.type);
|
|
56
53
|
options.ease = supportsLinearEasing()
|
|
@@ -62,92 +59,35 @@ class NativeAnimation {
|
|
|
62
59
|
else {
|
|
63
60
|
options.ease = options.ease || defaultEasing;
|
|
64
61
|
}
|
|
65
|
-
this.removeAnimation = () => { var _a; return (_a = state.get(element)) === null || _a === void 0 ? void 0 : _a.delete(valueName); };
|
|
66
62
|
const onFinish = () => {
|
|
67
|
-
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes,
|
|
63
|
+
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, options));
|
|
68
64
|
this.cancel();
|
|
69
65
|
this.resolveFinishedPromise();
|
|
70
66
|
};
|
|
67
|
+
const init = () => {
|
|
68
|
+
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
69
|
+
this.options = options;
|
|
70
|
+
this.updateFinishedPromise();
|
|
71
|
+
this.removeAnimation = () => {
|
|
72
|
+
const elementState = state.get(element);
|
|
73
|
+
elementState && elementState.delete(valueName);
|
|
74
|
+
};
|
|
75
|
+
};
|
|
71
76
|
if (!supportsWaapi()) {
|
|
77
|
+
super();
|
|
78
|
+
init();
|
|
72
79
|
onFinish();
|
|
73
80
|
}
|
|
74
81
|
else {
|
|
75
|
-
|
|
82
|
+
super(startWaapiAnimation(element, valueName, valueKeyframes, options));
|
|
83
|
+
init();
|
|
76
84
|
if (options.autoplay === false) {
|
|
77
85
|
this.animation.pause();
|
|
78
86
|
}
|
|
79
87
|
this.animation.onfinish = onFinish;
|
|
80
|
-
if (this.pendingTimeline) {
|
|
81
|
-
attachTimeline(this.animation, this.pendingTimeline);
|
|
82
|
-
}
|
|
83
88
|
getElementAnimationState(element).set(valueName, this);
|
|
84
89
|
}
|
|
85
90
|
}
|
|
86
|
-
get duration() {
|
|
87
|
-
return millisecondsToSeconds(this.options.duration || 300);
|
|
88
|
-
}
|
|
89
|
-
get time() {
|
|
90
|
-
var _a;
|
|
91
|
-
if (this.animation) {
|
|
92
|
-
return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
|
|
93
|
-
}
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
set time(newTime) {
|
|
97
|
-
if (this.animation) {
|
|
98
|
-
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
get speed() {
|
|
102
|
-
return this.animation ? this.animation.playbackRate : 1;
|
|
103
|
-
}
|
|
104
|
-
set speed(newSpeed) {
|
|
105
|
-
if (this.animation) {
|
|
106
|
-
this.animation.playbackRate = newSpeed;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
get state() {
|
|
110
|
-
return this.animation ? this.animation.playState : "finished";
|
|
111
|
-
}
|
|
112
|
-
get startTime() {
|
|
113
|
-
return this.animation ? this.animation.startTime : null;
|
|
114
|
-
}
|
|
115
|
-
flatten() {
|
|
116
|
-
var _a;
|
|
117
|
-
if (!this.animation)
|
|
118
|
-
return;
|
|
119
|
-
(_a = this.animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming({ easing: "linear" });
|
|
120
|
-
}
|
|
121
|
-
play() {
|
|
122
|
-
if (this.state === "finished") {
|
|
123
|
-
this.updateFinishedPromise();
|
|
124
|
-
}
|
|
125
|
-
this.animation && this.animation.play();
|
|
126
|
-
}
|
|
127
|
-
pause() {
|
|
128
|
-
this.animation && this.animation.pause();
|
|
129
|
-
}
|
|
130
|
-
stop() {
|
|
131
|
-
if (!this.animation ||
|
|
132
|
-
this.state === "idle" ||
|
|
133
|
-
this.state === "finished") {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (this.animation.commitStyles) {
|
|
137
|
-
this.animation.commitStyles();
|
|
138
|
-
}
|
|
139
|
-
this.cancel();
|
|
140
|
-
}
|
|
141
|
-
complete() {
|
|
142
|
-
this.animation && this.animation.finish();
|
|
143
|
-
}
|
|
144
|
-
cancel() {
|
|
145
|
-
this.removeAnimation();
|
|
146
|
-
try {
|
|
147
|
-
this.animation && this.animation.cancel();
|
|
148
|
-
}
|
|
149
|
-
catch (e) { }
|
|
150
|
-
}
|
|
151
91
|
/**
|
|
152
92
|
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
153
93
|
* resolves when the animation finishes at all but in a future update could/should
|
|
@@ -161,14 +101,15 @@ class NativeAnimation {
|
|
|
161
101
|
this.resolveFinishedPromise = resolve;
|
|
162
102
|
});
|
|
163
103
|
}
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
this.
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
attachTimeline(this.animation, timeline);
|
|
104
|
+
play() {
|
|
105
|
+
if (this.state === "finished") {
|
|
106
|
+
this.updateFinishedPromise();
|
|
170
107
|
}
|
|
171
|
-
|
|
108
|
+
super.play();
|
|
109
|
+
}
|
|
110
|
+
cancel() {
|
|
111
|
+
this.removeAnimation();
|
|
112
|
+
super.cancel();
|
|
172
113
|
}
|
|
173
114
|
}
|
|
174
115
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { invariant } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { getValueTransition } from '../../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
4
|
+
import { resolveElements } from '../../../../../../motion-dom/dist/es/utils/resolve-elements.mjs';
|
|
5
5
|
import { NativeAnimation } from './NativeAnimation.mjs';
|
|
6
6
|
|
|
7
7
|
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GroupPlaybackControls } from '../../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
3
|
+
import { createAnimationsFromSequence } from '../../sequence/create.mjs';
|
|
4
|
+
import { animateElements } from './animate-elements.mjs';
|
|
5
|
+
|
|
6
|
+
function animateSequence(definition, options) {
|
|
7
|
+
const animations = [];
|
|
8
|
+
createAnimationsFromSequence(definition, options).forEach(({ keyframes, transition }, element) => {
|
|
9
|
+
animations.push(...animateElements(element, keyframes, transition));
|
|
10
|
+
});
|
|
11
|
+
return new GroupPlaybackControls(animations);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { animateSequence };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GroupPlaybackControls } from '
|
|
1
|
+
import { GroupPlaybackControls } from '../../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
3
|
import { animateElements } from './animate-elements.mjs';
|
|
3
4
|
|
|
4
5
|
const createScopedWaapiAnimate = (scope) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { mapEasingToNativeEasing } from '../../../../../../motion-dom/dist/es/animation/waapi/utils/easing.mjs';
|
|
2
3
|
|
|
3
4
|
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
4
5
|
const keyframeOptions = { [valueName]: keyframes };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { memo } from '../../../../../../../motion-utils/dist/es/memo.mjs';
|
|
2
3
|
|
|
3
4
|
const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
4
5
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const springDefaults = {
|
|
2
|
+
// Default spring physics
|
|
3
|
+
stiffness: 100,
|
|
4
|
+
damping: 10,
|
|
5
|
+
mass: 1.0,
|
|
6
|
+
velocity: 0.0,
|
|
7
|
+
// Default duration/bounce-based options
|
|
8
|
+
duration: 800, // in ms
|
|
9
|
+
bounce: 0.3,
|
|
10
|
+
visualDuration: 0.3, // in seconds
|
|
11
|
+
// Rest thresholds
|
|
12
|
+
restSpeed: {
|
|
13
|
+
granular: 0.01,
|
|
14
|
+
default: 2,
|
|
15
|
+
},
|
|
16
|
+
restDelta: {
|
|
17
|
+
granular: 0.005,
|
|
18
|
+
default: 0.5,
|
|
19
|
+
},
|
|
20
|
+
// Limits
|
|
21
|
+
minDuration: 0.01, // in seconds
|
|
22
|
+
maxDuration: 10.0, // in seconds
|
|
23
|
+
minDamping: 0.05,
|
|
24
|
+
maxDamping: 1,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { springDefaults };
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { warning } from '
|
|
1
|
+
import { warning } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { secondsToMilliseconds, millisecondsToSeconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
2
3
|
import { clamp } from '../../../utils/clamp.mjs';
|
|
3
|
-
import {
|
|
4
|
+
import { springDefaults } from './defaults.mjs';
|
|
4
5
|
|
|
5
6
|
const safeMin = 0.001;
|
|
6
|
-
|
|
7
|
-
const maxDuration = 10.0;
|
|
8
|
-
const minDamping = 0.05;
|
|
9
|
-
const maxDamping = 1;
|
|
10
|
-
function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, }) {
|
|
7
|
+
function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass, }) {
|
|
11
8
|
let envelope;
|
|
12
9
|
let derivative;
|
|
13
|
-
warning(duration <= secondsToMilliseconds(maxDuration), "Spring duration must be 10 seconds or less");
|
|
10
|
+
warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
|
|
14
11
|
let dampingRatio = 1 - bounce;
|
|
15
12
|
/**
|
|
16
13
|
* Restrict dampingRatio and duration to within acceptable ranges.
|
|
17
14
|
*/
|
|
18
|
-
dampingRatio = clamp(minDamping, maxDamping, dampingRatio);
|
|
19
|
-
duration = clamp(minDuration, maxDuration, millisecondsToSeconds(duration));
|
|
15
|
+
dampingRatio = clamp(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
|
|
16
|
+
duration = clamp(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds(duration));
|
|
20
17
|
if (dampingRatio < 1) {
|
|
21
18
|
/**
|
|
22
19
|
* Underdamped spring
|
|
@@ -60,8 +57,8 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
60
57
|
duration = secondsToMilliseconds(duration);
|
|
61
58
|
if (isNaN(undampedFreq)) {
|
|
62
59
|
return {
|
|
63
|
-
stiffness:
|
|
64
|
-
damping:
|
|
60
|
+
stiffness: springDefaults.stiffness,
|
|
61
|
+
damping: springDefaults.damping,
|
|
65
62
|
duration,
|
|
66
63
|
};
|
|
67
64
|
}
|
|
@@ -86,4 +83,4 @@ function calcAngularFreq(undampedFreq, dampingRatio) {
|
|
|
86
83
|
return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
|
|
87
84
|
}
|
|
88
85
|
|
|
89
|
-
export { calcAngularFreq, findSpring
|
|
86
|
+
export { calcAngularFreq, findSpring };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { calcGeneratorDuration, maxGeneratorDuration } from '../../../../../../motion-dom/dist/es/animation/generators/utils/calc-duration.mjs';
|
|
4
|
+
import { generateLinearEasing } from '../../../../../../motion-dom/dist/es/animation/waapi/utils/linear.mjs';
|
|
5
|
+
import { clamp } from '../../../utils/clamp.mjs';
|
|
2
6
|
import { calcGeneratorVelocity } from '../utils/velocity.mjs';
|
|
7
|
+
import { springDefaults } from './defaults.mjs';
|
|
3
8
|
import { findSpring, calcAngularFreq } from './find.mjs';
|
|
4
9
|
|
|
5
10
|
const durationKeys = ["duration", "bounce"];
|
|
@@ -9,29 +14,53 @@ function isSpringType(options, keys) {
|
|
|
9
14
|
}
|
|
10
15
|
function getSpringOptions(options) {
|
|
11
16
|
let springOptions = {
|
|
12
|
-
velocity:
|
|
13
|
-
stiffness:
|
|
14
|
-
damping:
|
|
15
|
-
mass:
|
|
17
|
+
velocity: springDefaults.velocity,
|
|
18
|
+
stiffness: springDefaults.stiffness,
|
|
19
|
+
damping: springDefaults.damping,
|
|
20
|
+
mass: springDefaults.mass,
|
|
16
21
|
isResolvedFromDuration: false,
|
|
17
22
|
...options,
|
|
18
23
|
};
|
|
19
24
|
// stiffness/damping/mass overrides duration/bounce
|
|
20
25
|
if (!isSpringType(options, physicsKeys) &&
|
|
21
26
|
isSpringType(options, durationKeys)) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (options.visualDuration) {
|
|
28
|
+
const visualDuration = options.visualDuration;
|
|
29
|
+
const root = (2 * Math.PI) / (visualDuration * 1.2);
|
|
30
|
+
const stiffness = root * root;
|
|
31
|
+
const damping = 2 *
|
|
32
|
+
clamp(0.05, 1, 1 - (options.bounce || 0)) *
|
|
33
|
+
Math.sqrt(stiffness);
|
|
34
|
+
springOptions = {
|
|
35
|
+
...springOptions,
|
|
36
|
+
mass: springDefaults.mass,
|
|
37
|
+
stiffness,
|
|
38
|
+
damping,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const derived = findSpring(options);
|
|
43
|
+
springOptions = {
|
|
44
|
+
...springOptions,
|
|
45
|
+
...derived,
|
|
46
|
+
mass: springDefaults.mass,
|
|
47
|
+
};
|
|
48
|
+
springOptions.isResolvedFromDuration = true;
|
|
49
|
+
}
|
|
29
50
|
}
|
|
30
51
|
return springOptions;
|
|
31
52
|
}
|
|
32
|
-
function spring(
|
|
33
|
-
const
|
|
34
|
-
|
|
53
|
+
function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
|
|
54
|
+
const options = typeof optionsOrVisualDuration !== "object"
|
|
55
|
+
? {
|
|
56
|
+
visualDuration: optionsOrVisualDuration,
|
|
57
|
+
keyframes: [0, 1],
|
|
58
|
+
bounce,
|
|
59
|
+
}
|
|
60
|
+
: optionsOrVisualDuration;
|
|
61
|
+
let { restSpeed, restDelta } = options;
|
|
62
|
+
const origin = options.keyframes[0];
|
|
63
|
+
const target = options.keyframes[options.keyframes.length - 1];
|
|
35
64
|
/**
|
|
36
65
|
* This is the Iterator-spec return value. We ensure it's mutable rather than using a generator
|
|
37
66
|
* to reduce GC during animation.
|
|
@@ -53,8 +82,12 @@ function spring({ keyframes, restDelta, restSpeed, ...options }) {
|
|
|
53
82
|
* ratio between feeling good and finishing as soon as changes are imperceptible.
|
|
54
83
|
*/
|
|
55
84
|
const isGranularScale = Math.abs(initialDelta) < 5;
|
|
56
|
-
restSpeed || (restSpeed = isGranularScale
|
|
57
|
-
|
|
85
|
+
restSpeed || (restSpeed = isGranularScale
|
|
86
|
+
? springDefaults.restSpeed.granular
|
|
87
|
+
: springDefaults.restSpeed.default);
|
|
88
|
+
restDelta || (restDelta = isGranularScale
|
|
89
|
+
? springDefaults.restDelta.granular
|
|
90
|
+
: springDefaults.restDelta.default);
|
|
58
91
|
let resolveSpring;
|
|
59
92
|
if (dampingRatio < 1) {
|
|
60
93
|
const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
|
|
@@ -95,7 +128,7 @@ function spring({ keyframes, restDelta, restSpeed, ...options }) {
|
|
|
95
128
|
dampedAngularFreq);
|
|
96
129
|
};
|
|
97
130
|
}
|
|
98
|
-
|
|
131
|
+
const generator = {
|
|
99
132
|
calculatedDuration: isResolvedFromDuration ? duration || null : null,
|
|
100
133
|
next: (t) => {
|
|
101
134
|
const current = resolveSpring(t);
|
|
@@ -123,7 +156,13 @@ function spring({ keyframes, restDelta, restSpeed, ...options }) {
|
|
|
123
156
|
state.value = state.done ? target : current;
|
|
124
157
|
return state;
|
|
125
158
|
},
|
|
159
|
+
toString: () => {
|
|
160
|
+
const calculatedDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
161
|
+
const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
162
|
+
return calculatedDuration + "ms " + easing;
|
|
163
|
+
},
|
|
126
164
|
};
|
|
165
|
+
return generator;
|
|
127
166
|
}
|
|
128
167
|
|
|
129
168
|
export { spring };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { GroupPlaybackControls } from '../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
|
+
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
3
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
4
|
+
import { secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
5
|
+
import { frame } from '../../frameloop/frame.mjs';
|
|
4
6
|
import { MotionGlobalConfig } from '../../utils/GlobalConfig.mjs';
|
|
5
7
|
import { instantAnimationState } from '../../utils/use-instant-transition-state.mjs';
|
|
6
|
-
import { getFinalKeyframe } from '../animators/waapi/utils/get-final-keyframe.mjs';
|
|
7
|
-
import { frame } from '../../frameloop/frame.mjs';
|
|
8
8
|
import { AcceleratedAnimation } from '../animators/AcceleratedAnimation.mjs';
|
|
9
9
|
import { MainThreadAnimation } from '../animators/MainThreadAnimation.mjs';
|
|
10
|
-
import {
|
|
10
|
+
import { getFinalKeyframe } from '../animators/waapi/utils/get-final-keyframe.mjs';
|
|
11
|
+
import { getDefaultTransition } from '../utils/default-transitions.mjs';
|
|
11
12
|
import { isTransitionDefined } from '../utils/is-transition-defined.mjs';
|
|
12
13
|
|
|
13
14
|
const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
3
|
+
import { positionalKeys } from '../../render/html/utils/keys-position.mjs';
|
|
3
4
|
import { setTarget } from '../../render/utils/setters.mjs';
|
|
4
|
-
import { getValueTransition } from '../utils/get-value-transition.mjs';
|
|
5
|
-
import { getOptimisedAppearId } from '../optimized-appear/get-appear-id.mjs';
|
|
6
5
|
import { addValueToWillChange } from '../../value/use-will-change/add-will-change.mjs';
|
|
6
|
+
import { getOptimisedAppearId } from '../optimized-appear/get-appear-id.mjs';
|
|
7
|
+
import { animateMotionValue } from './motion-value.mjs';
|
|
7
8
|
import { frame } from '../../frameloop/frame.mjs';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -54,7 +55,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
addValueToWillChange(visualElement, key);
|
|
57
|
-
value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion &&
|
|
58
|
+
value.start(animateMotionValue(key, value, valueTarget, visualElement.shouldReduceMotion && positionalKeys.has(key)
|
|
58
59
|
? { type: false }
|
|
59
60
|
: valueTransition, visualElement, isHandoff));
|
|
60
61
|
const animation = value.animation;
|
|
@@ -3,7 +3,8 @@ import { startWaapiAnimation } from '../animators/waapi/index.mjs';
|
|
|
3
3
|
import { optimizedAppearDataId } from './data-id.mjs';
|
|
4
4
|
import { handoffOptimizedAppearAnimation } from './handoff.mjs';
|
|
5
5
|
import { appearAnimationStore, appearComplete } from './store.mjs';
|
|
6
|
-
import
|
|
6
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
7
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
7
8
|
import { getOptimisedAppearId } from './get-appear-id.mjs';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transformProps } from '../../render/html/utils/transform.mjs';
|
|
1
|
+
import { transformProps } from '../../render/html/utils/keys-transform.mjs';
|
|
2
2
|
|
|
3
3
|
const appearStoreId = (elementId, valueName) => {
|
|
4
4
|
const key = transformProps.has(valueName) ? "transform" : valueName;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { progress } from '../../../../../motion-utils/dist/es/progress.mjs';
|
|
3
|
+
import { secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
+
import { createGeneratorEasing } from '../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
|
|
5
|
+
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
6
|
+
import { getEasingForSegment } from '../../easing/utils/get-easing-for-segment.mjs';
|
|
2
7
|
import { defaultOffset } from '../../utils/offsets/default.mjs';
|
|
3
8
|
import { fillOffset } from '../../utils/offsets/fill.mjs';
|
|
4
|
-
import { progress } from '../../utils/progress.mjs';
|
|
5
|
-
import { secondsToMilliseconds } from '../../utils/time-conversion.mjs';
|
|
6
9
|
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
7
10
|
import { resolveSubjects } from '../animate/resolve-subjects.mjs';
|
|
8
|
-
import {
|
|
11
|
+
import { calculateRepeatDuration } from './utils/calc-repeat-duration.mjs';
|
|
9
12
|
import { calcNextTime } from './utils/calc-time.mjs';
|
|
10
13
|
import { addKeyframes } from './utils/edit.mjs';
|
|
14
|
+
import { normalizeTimes } from './utils/normalize-times.mjs';
|
|
11
15
|
import { compareByTime } from './utils/sort.mjs';
|
|
12
16
|
|
|
13
17
|
const defaultSegmentEasing = "easeInOut";
|
|
18
|
+
const MAX_REPEAT = 20;
|
|
14
19
|
function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...sequenceTransition } = {}, scope, generators) {
|
|
15
20
|
const defaultDuration = defaultTransition.duration || 0.3;
|
|
16
21
|
const animationDefinitions = new Map();
|
|
@@ -53,7 +58,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
53
58
|
let maxDuration = 0;
|
|
54
59
|
const resolveValueSequence = (valueKeyframes, valueTransition, valueSequence, elementIndex = 0, numSubjects = 0) => {
|
|
55
60
|
const valueKeyframesAsList = keyframesAsList(valueKeyframes);
|
|
56
|
-
const { delay = 0, times = defaultOffset(valueKeyframesAsList), type = "keyframes", ...remainingTransition } = valueTransition;
|
|
61
|
+
const { delay = 0, times = defaultOffset(valueKeyframesAsList), type = "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
|
|
57
62
|
let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
|
|
58
63
|
/**
|
|
59
64
|
* Resolve stagger() if defined.
|
|
@@ -91,7 +96,6 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
91
96
|
}
|
|
92
97
|
duration !== null && duration !== void 0 ? duration : (duration = defaultDuration);
|
|
93
98
|
const startTime = currentTime + calculatedDelay;
|
|
94
|
-
const targetTime = startTime + duration;
|
|
95
99
|
/**
|
|
96
100
|
* If there's only one time offset of 0, fill in a second with length 1
|
|
97
101
|
*/
|
|
@@ -110,6 +114,28 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
110
114
|
*/
|
|
111
115
|
valueKeyframesAsList.length === 1 &&
|
|
112
116
|
valueKeyframesAsList.unshift(null);
|
|
117
|
+
/**
|
|
118
|
+
* Handle repeat options
|
|
119
|
+
*/
|
|
120
|
+
if (repeat) {
|
|
121
|
+
invariant(repeat < MAX_REPEAT, "Repeat count too high, must be less than 20");
|
|
122
|
+
duration = calculateRepeatDuration(duration, repeat);
|
|
123
|
+
const originalKeyframes = [...valueKeyframesAsList];
|
|
124
|
+
const originalTimes = [...times];
|
|
125
|
+
ease = Array.isArray(ease) ? [...ease] : [ease];
|
|
126
|
+
const originalEase = [...ease];
|
|
127
|
+
for (let repeatIndex = 0; repeatIndex < repeat; repeatIndex++) {
|
|
128
|
+
valueKeyframesAsList.push(...originalKeyframes);
|
|
129
|
+
for (let keyframeIndex = 0; keyframeIndex < originalKeyframes.length; keyframeIndex++) {
|
|
130
|
+
times.push(originalTimes[keyframeIndex] + (repeatIndex + 1));
|
|
131
|
+
ease.push(keyframeIndex === 0
|
|
132
|
+
? "linear"
|
|
133
|
+
: getEasingForSegment(originalEase, keyframeIndex - 1));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
normalizeTimes(times, repeat);
|
|
137
|
+
}
|
|
138
|
+
const targetTime = startTime + duration;
|
|
113
139
|
/**
|
|
114
140
|
* Add keyframes, mapping offsets to absolute time.
|
|
115
141
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Take an array of times that represent repeated keyframes. For instance
|
|
3
|
+
* if we have original times of [0, 0.5, 1] then our repeated times will
|
|
4
|
+
* be [0, 0.5, 1, 1, 1.5, 2]. Loop over the times and scale them back
|
|
5
|
+
* down to a 0-1 scale.
|
|
6
|
+
*/
|
|
7
|
+
function normalizeTimes(times, repeat) {
|
|
8
|
+
for (let i = 0; i < times.length; i++) {
|
|
9
|
+
times[i] = times[i] / (repeat + 1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { normalizeTimes };
|