motion 12.7.4 → 12.7.5-alpha.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/README.md +1 -1
- package/dist/cjs/debug.js +22 -14
- package/dist/cjs/index.js +4113 -3624
- package/dist/cjs/mini.js +403 -324
- package/dist/cjs/react-client.js +3151 -3245
- package/dist/cjs/react-m.js +169 -166
- package/dist/cjs/react-mini.js +330 -251
- package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +81 -9
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +11 -30
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +1 -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 +3 -3
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -2
- package/dist/es/framer-motion/dist/es/gestures/focus.mjs +1 -1
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -3
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +2 -2
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +3 -5
- package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +2 -2
- package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +7 -7
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-animation.mjs +17 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-function.mjs +23 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +6 -82
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/dom/scroll/utils/get-timeline.mjs +29 -0
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +4 -4
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +2 -2
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/path.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/svg/utils/transform-origin.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 +1 -1
- package/dist/es/framer-motion/dist/es/utils/transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/use-cycle.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +4 -4
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +2 -2
- package/dist/es/motion/lib/index.mjs +109 -26
- package/dist/es/motion/lib/react.mjs +108 -32
- package/dist/es/motion-dom/dist/es/animation/AsyncMotionValueAnimation.mjs +179 -0
- package/dist/es/motion-dom/dist/es/animation/GroupAnimation.mjs +6 -15
- package/dist/es/{framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs → motion-dom/dist/es/animation/JSAnimation.mjs} +108 -156
- package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +64 -67
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationExtended.mjs +65 -0
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationWrapper.mjs +14 -0
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/drivers/driver-frameloop.mjs +2 -2
- package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/keyframes.mjs +5 -5
- package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/find.mjs +1 -1
- package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/index.mjs +5 -6
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation/keyframes}/DOMKeyframesResolver.mjs +9 -8
- package/dist/es/{framer-motion/dist/es/render/utils → motion-dom/dist/es/animation/keyframes}/KeyframesResolver.mjs +28 -35
- package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +3 -4
- package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/animation/keyframes}/offsets/fill.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +11 -0
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.mjs +7 -0
- package/dist/es/{framer-motion/dist/es/animation → motion-dom/dist/es/animation/keyframes}/utils/is-none.mjs +1 -1
- package/dist/es/{framer-motion/dist/es/render/html → motion-dom/dist/es/animation/keyframes}/utils/make-none-animatable.mjs +1 -1
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation/keyframes}/utils/unit-conversion.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/utils/WithPromise.mjs +28 -0
- package/dist/es/motion-dom/dist/es/animation/utils/active-animations.mjs +9 -0
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/utils/can-animate.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation}/utils/css-variables-conversion.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/utils/replace-transition-type.mjs +18 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +1 -1
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +5 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs +6 -4
- package/dist/es/motion-dom/dist/es/animation/waapi/supports/waapi.mjs +39 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +2 -1
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/unsupported-easing.mjs +20 -0
- package/dist/es/motion-dom/dist/es/frameloop/batcher.mjs +2 -1
- package/dist/es/motion-dom/dist/es/frameloop/order.mjs +1 -0
- package/dist/es/motion-dom/dist/es/render/dom/is-css-var.mjs +3 -0
- package/dist/es/motion-dom/dist/es/render/dom/style-computed.mjs +10 -0
- package/dist/es/motion-dom/dist/es/render/dom/style-set.mjs +9 -0
- package/dist/es/{framer-motion/dist/es/render/html → motion-dom/dist/es/render}/utils/keys-transform.mjs +1 -1
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es}/scroll/observe.mjs +1 -1
- package/dist/es/motion-dom/dist/es/stats/index.mjs +2 -0
- package/dist/es/{framer-motion → motion-dom}/dist/es/utils/interpolate.mjs +4 -3
- package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/color.mjs +3 -3
- package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/complex.mjs +5 -5
- package/dist/es/motion-dom/dist/es/value/index.mjs +3 -1
- package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/rgba.mjs +2 -2
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types}/dimensions.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/render/dom/value-types/type-int.mjs → motion-dom/dist/es/value/types/int.mjs} +1 -1
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/maps}/defaults.mjs +2 -2
- package/dist/es/{framer-motion/dist/es/render/dom/value-types/number-browser.mjs → motion-dom/dist/es/value/types/maps/number.mjs} +13 -3
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/maps}/transform.mjs +2 -2
- package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/numbers/index.mjs +1 -1
- package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/numbers/units.mjs +3 -2
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/utils}/animatable-none.mjs +4 -4
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/utils}/find.mjs +4 -4
- package/dist/es/motion-dom/dist/es/view/index.mjs +64 -0
- package/dist/es/motion-dom/dist/es/view/queue.mjs +52 -0
- package/dist/es/motion-dom/dist/es/view/start.mjs +155 -0
- package/dist/es/motion-dom/dist/es/view/utils/choose-layer-type.mjs +11 -0
- package/dist/es/motion-dom/dist/es/view/utils/css.mjs +32 -0
- package/dist/es/motion-dom/dist/es/view/utils/get-layer-name.mjs +8 -0
- package/dist/es/motion-dom/dist/es/view/utils/get-view-animations.mjs +12 -0
- package/dist/es/motion-dom/dist/es/view/utils/has-target.mjs +5 -0
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/cubic-bezier.mjs +1 -1
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/steps.mjs +1 -1
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/utils/get-easing-for-segment.mjs +1 -1
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/utils/map.mjs +7 -4
- package/dist/es/motion-utils/dist/es/global-config.mjs +1 -4
- package/dist/es/motion-utils/dist/es/warn-once.mjs +4 -1
- package/dist/motion.dev.js +4108 -3619
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +0 -324
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +0 -120
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
- package/dist/es/framer-motion/dist/es/render/dom/value-types/number.mjs +0 -18
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition-state.mjs +0 -5
- package/dist/es/motion-dom/dist/es/animation/keyframes/hydrate.mjs +0 -26
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs +0 -6
- package/dist/es/motion-dom/dist/es/render/dom/style.mjs +0 -15
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/inertia.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/defaults.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/velocity.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/animation/keyframes}/offsets/default.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/animation/keyframes}/offsets/time.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/is-animatable.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation}/utils/is-css-variable.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation/waapi}/utils/accelerated-values.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/html/utils → motion-dom/dist/es/render/dom}/parse-transform.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/html → motion-dom/dist/es/render}/utils/keys-position.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/immediate.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/index.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/number.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/visibility.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom/value-types/type-auto.mjs → motion-dom/dist/es/value/types/auto.mjs} +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/hex.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/value/types/color}/hsla-to-rgba.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/hsla.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/index.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/utils.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/complex/filter.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/complex/index.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types}/test.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/color-regex.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/float-regex.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/utils}/get-as-type.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/is-nullish.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/sanitize.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/single-color-regex.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/clamp.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/anticipate.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/back.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/circ.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/ease.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/modifiers/mirror.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/modifiers/reverse.mjs +0 -0
- /package/dist/es/{motion-dom/dist/es → motion-utils/dist/es/easing}/utils/is-bezier-definition.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/utils/is-easing-array.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/is-numerical-string.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/is-zero-value-string.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/pipe.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/wrap.mjs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { spring } from '../generators/spring/index.mjs';
|
|
2
1
|
import { createAnimationsFromSequence } from '../sequence/create.mjs';
|
|
3
2
|
import { animateSubject } from './subject.mjs';
|
|
3
|
+
import { spring } from '../../../../../motion-dom/dist/es/animation/generators/spring/index.mjs';
|
|
4
4
|
|
|
5
5
|
function animateSequence(sequence, options, scope) {
|
|
6
6
|
const animations = [];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { resolveElements } from '../../../../../../motion-dom/dist/es/utils/resolve-elements.mjs';
|
|
2
2
|
import { invariant } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
3
3
|
import { getValueTransition } from '../../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
4
|
+
import { getAnimationMap, animationMapKey } from '../../../../../../motion-dom/dist/es/animation/utils/active-animations.mjs';
|
|
5
|
+
import { getComputedStyle } from '../../../../../../motion-dom/dist/es/render/dom/style-computed.mjs';
|
|
6
|
+
import { fillWildcards } from '../../../../../../motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.mjs';
|
|
7
|
+
import { applyPxDefaults } from '../../../../../../motion-dom/dist/es/animation/keyframes/utils/apply-px-defaults.mjs';
|
|
4
8
|
import { NativeAnimation } from '../../../../../../motion-dom/dist/es/animation/NativeAnimation.mjs';
|
|
5
9
|
import { secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
6
10
|
|
|
@@ -8,7 +12,27 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
8
12
|
const elements = resolveElements(elementOrSelector, scope);
|
|
9
13
|
const numElements = elements.length;
|
|
10
14
|
invariant(Boolean(numElements), "No valid element provided.");
|
|
11
|
-
|
|
15
|
+
/**
|
|
16
|
+
* WAAPI doesn't support interrupting animations.
|
|
17
|
+
*
|
|
18
|
+
* Therefore, starting animations requires a three-step process:
|
|
19
|
+
* 1. Stop existing animations (write styles to DOM)
|
|
20
|
+
* 2. Resolve keyframes (read styles from DOM)
|
|
21
|
+
* 3. Create new animations (write styles to DOM)
|
|
22
|
+
*
|
|
23
|
+
* The hybrid `animate()` function uses AsyncAnimation to resolve
|
|
24
|
+
* keyframes before creating new animations, which removes style
|
|
25
|
+
* thrashing. Here, we have much stricter filesize constraints.
|
|
26
|
+
* Therefore we do this in a synchronous way that ensures that
|
|
27
|
+
* at least within `animate()` calls there is no style thrashing.
|
|
28
|
+
*
|
|
29
|
+
* In the motion-native-animate-mini-interrupt benchmark this
|
|
30
|
+
* was 80% faster than a single loop.
|
|
31
|
+
*/
|
|
32
|
+
const animationDefinitions = [];
|
|
33
|
+
/**
|
|
34
|
+
* Step 1: Build options and stop existing animations (write)
|
|
35
|
+
*/
|
|
12
36
|
for (let i = 0; i < numElements; i++) {
|
|
13
37
|
const element = elements[i];
|
|
14
38
|
const elementTransition = { ...options };
|
|
@@ -19,20 +43,68 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
19
43
|
elementTransition.delay = elementTransition.delay(i, numElements);
|
|
20
44
|
}
|
|
21
45
|
for (const valueName in keyframes) {
|
|
22
|
-
|
|
46
|
+
let valueKeyframes = keyframes[valueName];
|
|
47
|
+
if (!Array.isArray(valueKeyframes)) {
|
|
48
|
+
valueKeyframes = [valueKeyframes];
|
|
49
|
+
}
|
|
23
50
|
const valueOptions = {
|
|
24
51
|
...getValueTransition(elementTransition, valueName),
|
|
25
52
|
};
|
|
26
53
|
valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
|
|
27
54
|
valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
55
|
+
/**
|
|
56
|
+
* If there's an existing animation playing on this element then stop it
|
|
57
|
+
* before creating a new one.
|
|
58
|
+
*/
|
|
59
|
+
const map = getAnimationMap(element);
|
|
60
|
+
const key = animationMapKey(valueName, valueOptions.pseudoElement || "");
|
|
61
|
+
const currentAnimation = map.get(key);
|
|
62
|
+
currentAnimation && currentAnimation.stop();
|
|
63
|
+
animationDefinitions.push({
|
|
64
|
+
map,
|
|
65
|
+
key,
|
|
66
|
+
unresolvedKeyframes: valueKeyframes,
|
|
67
|
+
options: {
|
|
68
|
+
...valueOptions,
|
|
69
|
+
element,
|
|
70
|
+
name: valueName,
|
|
71
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Step 2: Resolve keyframes (read)
|
|
78
|
+
*/
|
|
79
|
+
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
80
|
+
const { unresolvedKeyframes, options: animationOptions } = animationDefinitions[i];
|
|
81
|
+
const { element, name, pseudoElement } = animationOptions;
|
|
82
|
+
if (!pseudoElement && unresolvedKeyframes[0] === null) {
|
|
83
|
+
unresolvedKeyframes[0] = getComputedStyle(element, name);
|
|
84
|
+
}
|
|
85
|
+
fillWildcards(unresolvedKeyframes);
|
|
86
|
+
applyPxDefaults(unresolvedKeyframes, name);
|
|
87
|
+
/**
|
|
88
|
+
* If we only have one keyframe, explicitly read the initial keyframe
|
|
89
|
+
* from the computed style. This is to ensure consistency with WAAPI behaviour
|
|
90
|
+
* for restarting animations, for instance .play() after finish, when it
|
|
91
|
+
* has one vs two keyframes.
|
|
92
|
+
*/
|
|
93
|
+
if (!pseudoElement && unresolvedKeyframes.length < 2) {
|
|
94
|
+
unresolvedKeyframes.unshift(getComputedStyle(element, name));
|
|
35
95
|
}
|
|
96
|
+
animationOptions.keyframes = unresolvedKeyframes;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Step 3: Create new animations (write)
|
|
100
|
+
*/
|
|
101
|
+
const animations = [];
|
|
102
|
+
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
103
|
+
const { map, key, options: animationOptions } = animationDefinitions[i];
|
|
104
|
+
const animation = new NativeAnimation(animationOptions);
|
|
105
|
+
map.set(key, animation);
|
|
106
|
+
animation.finished.finally(() => map.delete(key));
|
|
107
|
+
animations.push(animation);
|
|
36
108
|
}
|
|
37
109
|
return animations;
|
|
38
110
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { instantAnimationState } from '../../utils/use-instant-transition-state.mjs';
|
|
2
|
-
import { AcceleratedAnimation } from '../animators/AcceleratedAnimation.mjs';
|
|
3
|
-
import { MainThreadAnimation } from '../animators/MainThreadAnimation.mjs';
|
|
4
1
|
import { getFinalKeyframe } from '../animators/waapi/utils/get-final-keyframe.mjs';
|
|
5
2
|
import { getDefaultTransition } from '../utils/default-transitions.mjs';
|
|
6
3
|
import { isTransitionDefined } from '../utils/is-transition-defined.mjs';
|
|
@@ -8,7 +5,7 @@ import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/
|
|
|
8
5
|
import { secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
9
6
|
import { MotionGlobalConfig } from '../../../../../motion-utils/dist/es/global-config.mjs';
|
|
10
7
|
import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
11
|
-
import {
|
|
8
|
+
import { AsyncMotionValueAnimation } from '../../../../../motion-dom/dist/es/animation/AsyncMotionValueAnimation.mjs';
|
|
12
9
|
|
|
13
10
|
const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
|
|
14
11
|
const valueTransition = getValueTransition(transition, name) || {};
|
|
@@ -24,7 +21,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
24
21
|
*/
|
|
25
22
|
let { elapsed = 0 } = transition;
|
|
26
23
|
elapsed = elapsed - secondsToMilliseconds(delay);
|
|
27
|
-
|
|
24
|
+
const options = {
|
|
28
25
|
keyframes: Array.isArray(target) ? target : [null, target],
|
|
29
26
|
ease: "easeOut",
|
|
30
27
|
velocity: value.getVelocity(),
|
|
@@ -47,22 +44,18 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
47
44
|
* unique transition settings for this value.
|
|
48
45
|
*/
|
|
49
46
|
if (!isTransitionDefined(valueTransition)) {
|
|
50
|
-
options
|
|
51
|
-
...options,
|
|
52
|
-
...getDefaultTransition(name, options),
|
|
53
|
-
};
|
|
47
|
+
Object.assign(options, getDefaultTransition(name, options));
|
|
54
48
|
}
|
|
55
49
|
/**
|
|
56
50
|
* Both WAAPI and our internal animation functions use durations
|
|
57
51
|
* as defined by milliseconds, while our external API defines them
|
|
58
52
|
* as seconds.
|
|
59
53
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
54
|
+
options.duration && (options.duration = secondsToMilliseconds(options.duration));
|
|
55
|
+
options.repeatDelay && (options.repeatDelay = secondsToMilliseconds(options.repeatDelay));
|
|
56
|
+
/**
|
|
57
|
+
* Support deprecated way to set initial value. Prefer keyframe syntax.
|
|
58
|
+
*/
|
|
66
59
|
if (options.from !== undefined) {
|
|
67
60
|
options.keyframes[0] = options.from;
|
|
68
61
|
}
|
|
@@ -74,7 +67,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
74
67
|
shouldSkip = true;
|
|
75
68
|
}
|
|
76
69
|
}
|
|
77
|
-
if (
|
|
70
|
+
if (MotionGlobalConfig.instantAnimations ||
|
|
78
71
|
MotionGlobalConfig.skipAnimations) {
|
|
79
72
|
shouldSkip = true;
|
|
80
73
|
options.duration = 0;
|
|
@@ -97,22 +90,10 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
97
90
|
options.onUpdate(finalKeyframe);
|
|
98
91
|
options.onComplete();
|
|
99
92
|
});
|
|
100
|
-
|
|
101
|
-
// than returning undefined
|
|
102
|
-
return new GroupAnimationWithThen([]);
|
|
93
|
+
return;
|
|
103
94
|
}
|
|
104
95
|
}
|
|
105
|
-
|
|
106
|
-
* Animate via WAAPI if possible. If this is a handoff animation, the optimised animation will be running via
|
|
107
|
-
* WAAPI. Therefore, this animation must be JS to ensure it runs "under" the
|
|
108
|
-
* optimised animation.
|
|
109
|
-
*/
|
|
110
|
-
if (!isHandoff && AcceleratedAnimation.supports(options)) {
|
|
111
|
-
return new AcceleratedAnimation(options);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return new MainThreadAnimation(options);
|
|
115
|
-
}
|
|
96
|
+
return new AsyncMotionValueAnimation(options);
|
|
116
97
|
};
|
|
117
98
|
|
|
118
99
|
export { animateMotionValue };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { positionalKeys } from '../../render/html/utils/keys-position.mjs';
|
|
2
1
|
import { setTarget } from '../../render/utils/setters.mjs';
|
|
3
2
|
import { addValueToWillChange } from '../../value/use-will-change/add-will-change.mjs';
|
|
4
3
|
import { getOptimisedAppearId } from '../optimized-appear/get-appear-id.mjs';
|
|
5
4
|
import { animateMotionValue } from './motion-value.mjs';
|
|
6
5
|
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
7
6
|
import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
7
|
+
import { positionalKeys } from '../../../../../motion-dom/dist/es/render/utils/keys-position.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Decide whether we should block this animation. Previously, we achieved this
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { transformProps } from '
|
|
1
|
+
import { transformProps } from '../../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
|
|
2
2
|
|
|
3
3
|
const appearStoreId = (elementId, valueName) => {
|
|
4
4
|
const key = transformProps.has(valueName) ? "transform" : valueName;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { getEasingForSegment } from '../../easing/utils/get-easing-for-segment.mjs';
|
|
2
|
-
import { defaultOffset } from '../../utils/offsets/default.mjs';
|
|
3
|
-
import { fillOffset } from '../../utils/offsets/fill.mjs';
|
|
4
1
|
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
5
2
|
import { resolveSubjects } from '../animate/resolve-subjects.mjs';
|
|
6
3
|
import { calculateRepeatDuration } from './utils/calc-repeat-duration.mjs';
|
|
@@ -8,9 +5,12 @@ import { calcNextTime } from './utils/calc-time.mjs';
|
|
|
8
5
|
import { addKeyframes } from './utils/edit.mjs';
|
|
9
6
|
import { normalizeTimes } from './utils/normalize-times.mjs';
|
|
10
7
|
import { compareByTime } from './utils/sort.mjs';
|
|
8
|
+
import { defaultOffset } from '../../../../../motion-dom/dist/es/animation/keyframes/offsets/default.mjs';
|
|
11
9
|
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
12
10
|
import { createGeneratorEasing } from '../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
|
|
11
|
+
import { fillOffset } from '../../../../../motion-dom/dist/es/animation/keyframes/offsets/fill.mjs';
|
|
13
12
|
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
13
|
+
import { getEasingForSegment } from '../../../../../motion-utils/dist/es/easing/utils/get-easing-for-segment.mjs';
|
|
14
14
|
import { progress } from '../../../../../motion-utils/dist/es/progress.mjs';
|
|
15
15
|
import { secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
16
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mixNumber } from '../../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
2
|
+
import { getEasingForSegment } from '../../../../../../motion-utils/dist/es/easing/utils/get-easing-for-segment.mjs';
|
|
3
3
|
import { removeItem } from '../../../../../../motion-utils/dist/es/array.mjs';
|
|
4
4
|
|
|
5
5
|
function eraseKeyframes(sequence, startTime, endTime) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mixNumber } from '
|
|
1
|
+
import { mixNumber } from '../../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
2
2
|
import { moveItem } from '../../../../../../motion-utils/dist/es/array.mjs';
|
|
3
3
|
|
|
4
4
|
function checkReorder(order, value, offset, velocity) {
|
|
@@ -9,14 +9,14 @@ import { eachAxis } from '../../projection/utils/each-axis.mjs';
|
|
|
9
9
|
import { measurePageBox } from '../../projection/utils/measure.mjs';
|
|
10
10
|
import { getContextWindow } from '../../utils/get-context-window.mjs';
|
|
11
11
|
import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
12
|
-
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
13
|
-
import { percent } from '../../value/types/numbers/units.mjs';
|
|
14
12
|
import { addValueToWillChange } from '../../value/use-will-change/add-will-change.mjs';
|
|
15
13
|
import { PanSession } from '../pan/PanSession.mjs';
|
|
16
14
|
import { applyConstraints, calcRelativeConstraints, resolveDragElastic, calcViewportConstraints, rebaseAxisConstraints, calcOrigin, defaultElastic } from './utils/constraints.mjs';
|
|
17
15
|
import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
18
16
|
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
19
17
|
import { setDragLock } from '../../../../../motion-dom/dist/es/gestures/drag/state/set-active.mjs';
|
|
18
|
+
import { percent } from '../../../../../motion-dom/dist/es/value/types/numbers/units.mjs';
|
|
19
|
+
import { mixNumber } from '../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
20
20
|
|
|
21
21
|
const elementDragControls = new WeakMap();
|
|
22
22
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calcLength } from '../../../projection/geometry/delta-calc.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import { mixNumber } from '../../../utils/mix/number.mjs';
|
|
2
|
+
import { mixNumber } from '../../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
4
3
|
import { progress } from '../../../../../../motion-utils/dist/es/progress.mjs';
|
|
4
|
+
import { clamp } from '../../../../../../motion-utils/dist/es/clamp.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Apply constraints to a point. These constraints are both physical along an
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addDomEvent } from '../events/add-dom-event.mjs';
|
|
2
2
|
import { Feature } from '../motion/features/Feature.mjs';
|
|
3
|
-
import { pipe } from '
|
|
3
|
+
import { pipe } from '../../../../motion-utils/dist/es/pipe.mjs';
|
|
4
4
|
|
|
5
5
|
class FocusGesture extends Feature {
|
|
6
6
|
constructor() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { addPointerEvent } from '../../events/add-pointer-event.mjs';
|
|
2
2
|
import { extractEventInfo } from '../../events/event-info.mjs';
|
|
3
3
|
import { distance2D } from '../../utils/distance.mjs';
|
|
4
|
-
import { pipe } from '../../utils/pipe.mjs';
|
|
5
4
|
import { frame, cancelFrame, frameData } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
6
5
|
import { isPrimaryPointer } from '../../../../../motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs';
|
|
6
|
+
import { pipe } from '../../../../../motion-utils/dist/es/pipe.mjs';
|
|
7
7
|
import { secondsToMilliseconds, millisecondsToSeconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scaleCorrectors } from '../../projection/styles/scale-correction.mjs';
|
|
2
|
-
import { transformProps } from '
|
|
2
|
+
import { transformProps } from '../../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
|
|
3
3
|
|
|
4
4
|
function isForcedMotionValue(key, { layout, layoutId }) {
|
|
5
5
|
return (transformProps.has(key) ||
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { percent, px } from '../../value/types/numbers/units.mjs';
|
|
1
|
+
import { mixNumber } from '../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
2
|
+
import { percent, px } from '../../../../../motion-dom/dist/es/value/types/numbers/units.mjs';
|
|
4
3
|
import { progress } from '../../../../../motion-utils/dist/es/progress.mjs';
|
|
4
|
+
import { circOut } from '../../../../../motion-utils/dist/es/easing/circ.mjs';
|
|
5
5
|
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
6
6
|
|
|
7
7
|
const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
2
|
-
import { percent } from '../../value/types/numbers/units.mjs';
|
|
3
1
|
import { scalePoint } from './delta-apply.mjs';
|
|
2
|
+
import { percent } from '../../../../../motion-dom/dist/es/value/types/numbers/units.mjs';
|
|
3
|
+
import { mixNumber } from '../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Remove a delta from a point. This is essentially the steps of applyPointDelta in reverse
|
|
@@ -2,9 +2,7 @@ import { animateSingleValue } from '../../animation/animate/single-value.mjs';
|
|
|
2
2
|
import { getOptimisedAppearId } from '../../animation/optimized-appear/get-appear-id.mjs';
|
|
3
3
|
import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
|
|
4
4
|
import { FlatTree } from '../../render/utils/flat-tree.mjs';
|
|
5
|
-
import { clamp } from '../../utils/clamp.mjs';
|
|
6
5
|
import { delay } from '../../utils/delay.mjs';
|
|
7
|
-
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
8
6
|
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
9
7
|
import { mixValues } from '../animation/mix-values.mjs';
|
|
10
8
|
import { copyBoxInto, copyAxisDeltaInto } from '../geometry/copy.mjs';
|
|
@@ -24,8 +22,10 @@ import { SubscriptionManager } from '../../../../../motion-utils/dist/es/subscri
|
|
|
24
22
|
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
25
23
|
import { cancelFrame, frameData, frameSteps, frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
26
24
|
import { time } from '../../../../../motion-dom/dist/es/frameloop/sync-time.mjs';
|
|
25
|
+
import { clamp } from '../../../../../motion-utils/dist/es/clamp.mjs';
|
|
27
26
|
import { microtask } from '../../../../../motion-dom/dist/es/frameloop/microtask.mjs';
|
|
28
27
|
import { activeAnimations } from '../../../../../motion-dom/dist/es/stats/animation-count.mjs';
|
|
28
|
+
import { mixNumber } from '../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
29
29
|
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
30
30
|
|
|
31
31
|
const metrics = {
|
|
@@ -1000,9 +1000,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1000
1000
|
}
|
|
1001
1001
|
setAnimationOrigin(delta, hasOnlyRelativeTargetChanged = false) {
|
|
1002
1002
|
const snapshot = this.snapshot;
|
|
1003
|
-
const snapshotLatestValues = snapshot
|
|
1004
|
-
? snapshot.latestValues
|
|
1005
|
-
: {};
|
|
1003
|
+
const snapshotLatestValues = snapshot ? snapshot.latestValues : {};
|
|
1006
1004
|
const mixedValues = { ...this.latestValues };
|
|
1007
1005
|
const targetDelta = createDelta();
|
|
1008
1006
|
if (!this.relativeParent ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { complex } from '../../../../../motion-dom/dist/es/value/types/complex/index.mjs';
|
|
2
|
+
import { mixNumber } from '../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
3
3
|
|
|
4
4
|
const correctBoxShadow = {
|
|
5
5
|
correct: (latest, { treeScale, projectionDelta }) => {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { featureDefinitions } from '../motion/features/definitions.mjs';
|
|
2
2
|
import { createBox } from '../projection/geometry/models.mjs';
|
|
3
|
-
import { isNumericalString } from '../utils/is-numerical-string.mjs';
|
|
4
|
-
import { isZeroValueString } from '../utils/is-zero-value-string.mjs';
|
|
5
3
|
import { initPrefersReducedMotion } from '../utils/reduced-motion/index.mjs';
|
|
6
4
|
import { hasReducedMotionListener, prefersReducedMotion } from '../utils/reduced-motion/state.mjs';
|
|
7
|
-
import { complex } from '../value/types/complex/index.mjs';
|
|
8
5
|
import { isMotionValue } from '../value/utils/is-motion-value.mjs';
|
|
9
|
-
import { getAnimatableNone } from './dom/value-types/animatable-none.mjs';
|
|
10
|
-
import { findValueType } from './dom/value-types/find.mjs';
|
|
11
|
-
import { transformProps } from './html/utils/keys-transform.mjs';
|
|
12
6
|
import { visualElementStore } from './store.mjs';
|
|
13
7
|
import { isControllingVariants, isVariantNode } from './utils/is-controlling-variants.mjs';
|
|
14
|
-
import { KeyframeResolver } from './utils/KeyframesResolver.mjs';
|
|
15
8
|
import { updateMotionValuesFromProps } from './utils/motion-values.mjs';
|
|
16
9
|
import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
|
|
10
|
+
import { KeyframeResolver } from '../../../../motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs';
|
|
17
11
|
import { time } from '../../../../motion-dom/dist/es/frameloop/sync-time.mjs';
|
|
18
12
|
import { frame, cancelFrame } from '../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
19
13
|
import { warnOnce } from '../../../../motion-utils/dist/es/warn-once.mjs';
|
|
14
|
+
import { transformProps } from '../../../../motion-dom/dist/es/render/utils/keys-transform.mjs';
|
|
20
15
|
import { motionValue } from '../../../../motion-dom/dist/es/value/index.mjs';
|
|
16
|
+
import { isNumericalString } from '../../../../motion-utils/dist/es/is-numerical-string.mjs';
|
|
17
|
+
import { isZeroValueString } from '../../../../motion-utils/dist/es/is-zero-value-string.mjs';
|
|
18
|
+
import { findValueType } from '../../../../motion-dom/dist/es/value/types/utils/find.mjs';
|
|
19
|
+
import { complex } from '../../../../motion-dom/dist/es/value/types/complex/index.mjs';
|
|
20
|
+
import { getAnimatableNone } from '../../../../motion-dom/dist/es/value/types/utils/animatable-none.mjs';
|
|
21
21
|
import { SubscriptionManager } from '../../../../motion-utils/dist/es/subscription-manager.mjs';
|
|
22
22
|
|
|
23
23
|
const propEventHandlers = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
2
2
|
import { VisualElement } from '../VisualElement.mjs';
|
|
3
|
-
import { DOMKeyframesResolver } from '
|
|
3
|
+
import { DOMKeyframesResolver } from '../../../../../motion-dom/dist/es/animation/keyframes/DOMKeyframesResolver.mjs';
|
|
4
4
|
|
|
5
5
|
class DOMVisualElement extends VisualElement {
|
|
6
6
|
constructor() {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getTimeline } from './utils/get-timeline.mjs';
|
|
2
|
+
import { observeTimeline } from '../../../../../../motion-dom/dist/es/scroll/observe.mjs';
|
|
3
|
+
|
|
4
|
+
function attachToAnimation(animation, options) {
|
|
5
|
+
const timeline = getTimeline(options);
|
|
6
|
+
return animation.attachTimeline({
|
|
7
|
+
timeline,
|
|
8
|
+
observe: (valueAnimation) => {
|
|
9
|
+
valueAnimation.pause();
|
|
10
|
+
return observeTimeline((progress) => {
|
|
11
|
+
valueAnimation.time = valueAnimation.duration * progress;
|
|
12
|
+
}, timeline);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { attachToAnimation };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { scrollInfo } from './track.mjs';
|
|
2
|
+
import { getTimeline } from './utils/get-timeline.mjs';
|
|
3
|
+
import { observeTimeline } from '../../../../../../motion-dom/dist/es/scroll/observe.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* If the onScroll function has two arguments, it's expecting
|
|
7
|
+
* more specific information about the scroll from scrollInfo.
|
|
8
|
+
*/
|
|
9
|
+
function isOnScrollWithInfo(onScroll) {
|
|
10
|
+
return onScroll.length === 2;
|
|
11
|
+
}
|
|
12
|
+
function attachToFunction(onScroll, options) {
|
|
13
|
+
if (isOnScrollWithInfo(onScroll)) {
|
|
14
|
+
return scrollInfo((info) => {
|
|
15
|
+
onScroll(info[options.axis].progress, info);
|
|
16
|
+
}, options);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return observeTimeline(onScroll, getTimeline(options));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { attachToFunction };
|
|
@@ -1,87 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { noop } from '../../../../../../motion-utils/dist/es/noop.mjs';
|
|
4
|
-
import { supportsScrollTimeline } from '../../../../../../motion-dom/dist/es/utils/supports/scroll-timeline.mjs';
|
|
1
|
+
import { attachToAnimation } from './attach-animation.mjs';
|
|
2
|
+
import { attachToFunction } from './attach-function.mjs';
|
|
5
3
|
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
if (source)
|
|
9
|
-
container = source;
|
|
10
|
-
// ScrollTimeline records progress as a percentage CSSUnitValue
|
|
11
|
-
const currentTime = { value: 0 };
|
|
12
|
-
const cancel = scrollInfo((info) => {
|
|
13
|
-
currentTime.value = info[axis].progress * 100;
|
|
14
|
-
}, { container, axis });
|
|
15
|
-
return { currentTime, cancel };
|
|
16
|
-
}
|
|
17
|
-
const timelineCache = new Map();
|
|
18
|
-
function getTimeline({ source, container = document.documentElement, axis = "y", } = {}) {
|
|
19
|
-
// Support legacy source argument. Deprecate later.
|
|
20
|
-
if (source)
|
|
21
|
-
container = source;
|
|
22
|
-
if (!timelineCache.has(container)) {
|
|
23
|
-
timelineCache.set(container, {});
|
|
24
|
-
}
|
|
25
|
-
const elementCache = timelineCache.get(container);
|
|
26
|
-
if (!elementCache[axis]) {
|
|
27
|
-
elementCache[axis] = supportsScrollTimeline()
|
|
28
|
-
? new ScrollTimeline({ source: container, axis })
|
|
29
|
-
: scrollTimelineFallback({ source: container, axis });
|
|
30
|
-
}
|
|
31
|
-
return elementCache[axis];
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* If the onScroll function has two arguments, it's expecting
|
|
35
|
-
* more specific information about the scroll from scrollInfo.
|
|
36
|
-
*/
|
|
37
|
-
function isOnScrollWithInfo(onScroll) {
|
|
38
|
-
return onScroll.length === 2;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Currently, we only support element tracking with `scrollInfo`, though in
|
|
42
|
-
* the future we can also offer ViewTimeline support.
|
|
43
|
-
*/
|
|
44
|
-
function needsElementTracking(options) {
|
|
45
|
-
return options && (options.target || options.offset);
|
|
46
|
-
}
|
|
47
|
-
function scrollFunction(onScroll, options) {
|
|
48
|
-
if (isOnScrollWithInfo(onScroll) || needsElementTracking(options)) {
|
|
49
|
-
return scrollInfo((info) => {
|
|
50
|
-
onScroll(info[options.axis].progress, info);
|
|
51
|
-
}, options);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return observeTimeline(onScroll, getTimeline(options));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function scrollAnimation(animation, options) {
|
|
58
|
-
animation.flatten();
|
|
59
|
-
if (needsElementTracking(options)) {
|
|
60
|
-
animation.pause();
|
|
61
|
-
return scrollInfo((info) => {
|
|
62
|
-
animation.time = animation.duration * info[options.axis].progress;
|
|
63
|
-
}, options);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const timeline = getTimeline(options);
|
|
67
|
-
if (animation.attachTimeline) {
|
|
68
|
-
return animation.attachTimeline(timeline, (valueAnimation) => {
|
|
69
|
-
valueAnimation.pause();
|
|
70
|
-
return observeTimeline((progress) => {
|
|
71
|
-
valueAnimation.time = valueAnimation.duration * progress;
|
|
72
|
-
}, timeline);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return noop;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function scroll(onScroll, { axis = "y", ...options } = {}) {
|
|
81
|
-
const optionsWithDefaults = { axis, ...options };
|
|
4
|
+
function scroll(onScroll, { axis = "y", container = document.documentElement, ...options } = {}) {
|
|
5
|
+
const optionsWithDefaults = { axis, container, ...options };
|
|
82
6
|
return typeof onScroll === "function"
|
|
83
|
-
?
|
|
84
|
-
:
|
|
7
|
+
? attachToFunction(onScroll, optionsWithDefaults)
|
|
8
|
+
: attachToAnimation(onScroll, optionsWithDefaults);
|
|
85
9
|
}
|
|
86
10
|
|
|
87
11
|
export { scroll };
|