motion 12.7.3 → 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/AnimatePresence/PresenceChild.mjs +26 -23
- 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,324 +0,0 @@
|
|
|
1
|
-
import { anticipate } from '../../easing/anticipate.mjs';
|
|
2
|
-
import { backInOut } from '../../easing/back.mjs';
|
|
3
|
-
import { circInOut } from '../../easing/circ.mjs';
|
|
4
|
-
import { DOMKeyframesResolver } from '../../render/dom/DOMKeyframesResolver.mjs';
|
|
5
|
-
import { BaseAnimation } from './BaseAnimation.mjs';
|
|
6
|
-
import { MainThreadAnimation } from './MainThreadAnimation.mjs';
|
|
7
|
-
import { acceleratedValues } from './utils/accelerated-values.mjs';
|
|
8
|
-
import { getFinalKeyframe } from './waapi/utils/get-final-keyframe.mjs';
|
|
9
|
-
import { supportsWaapi } from './waapi/utils/supports-waapi.mjs';
|
|
10
|
-
import { supportsLinearEasing } from '../../../../../motion-dom/dist/es/utils/supports/linear-easing.mjs';
|
|
11
|
-
import { startWaapiAnimation } from '../../../../../motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs';
|
|
12
|
-
import { attachTimeline } from '../../../../../motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs';
|
|
13
|
-
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
14
|
-
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
15
|
-
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
16
|
-
import { isWaapiSupportedEasing } from '../../../../../motion-dom/dist/es/animation/waapi/easing/is-supported.mjs';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 10ms is chosen here as it strikes a balance between smooth
|
|
20
|
-
* results (more than one keyframe per frame at 60fps) and
|
|
21
|
-
* keyframe quantity.
|
|
22
|
-
*/
|
|
23
|
-
const sampleDelta = 10; //ms
|
|
24
|
-
/**
|
|
25
|
-
* Implement a practical max duration for keyframe generation
|
|
26
|
-
* to prevent infinite loops
|
|
27
|
-
*/
|
|
28
|
-
const maxDuration = 20000;
|
|
29
|
-
/**
|
|
30
|
-
* Check if an animation can run natively via WAAPI or requires pregenerated keyframes.
|
|
31
|
-
* WAAPI doesn't support spring or function easings so we run these as JS animation before
|
|
32
|
-
* handing off.
|
|
33
|
-
*/
|
|
34
|
-
function requiresPregeneratedKeyframes(options) {
|
|
35
|
-
return (isGenerator(options.type) ||
|
|
36
|
-
options.type === "spring" ||
|
|
37
|
-
!isWaapiSupportedEasing(options.ease));
|
|
38
|
-
}
|
|
39
|
-
function pregenerateKeyframes(keyframes, options) {
|
|
40
|
-
/**
|
|
41
|
-
* Create a main-thread animation to pregenerate keyframes.
|
|
42
|
-
* We sample this at regular intervals to generate keyframes that we then
|
|
43
|
-
* linearly interpolate between.
|
|
44
|
-
*/
|
|
45
|
-
const sampleAnimation = new MainThreadAnimation({
|
|
46
|
-
...options,
|
|
47
|
-
keyframes,
|
|
48
|
-
repeat: 0,
|
|
49
|
-
delay: 0,
|
|
50
|
-
isGenerator: true,
|
|
51
|
-
});
|
|
52
|
-
let state = { done: false, value: keyframes[0] };
|
|
53
|
-
const pregeneratedKeyframes = [];
|
|
54
|
-
/**
|
|
55
|
-
* Bail after 20 seconds of pre-generated keyframes as it's likely
|
|
56
|
-
* we're heading for an infinite loop.
|
|
57
|
-
*/
|
|
58
|
-
let t = 0;
|
|
59
|
-
while (!state.done && t < maxDuration) {
|
|
60
|
-
state = sampleAnimation.sample(t);
|
|
61
|
-
pregeneratedKeyframes.push(state.value);
|
|
62
|
-
t += sampleDelta;
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
times: undefined,
|
|
66
|
-
keyframes: pregeneratedKeyframes,
|
|
67
|
-
duration: t - sampleDelta,
|
|
68
|
-
ease: "linear",
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const unsupportedEasingFunctions = {
|
|
72
|
-
anticipate,
|
|
73
|
-
backInOut,
|
|
74
|
-
circInOut,
|
|
75
|
-
};
|
|
76
|
-
function isUnsupportedEase(key) {
|
|
77
|
-
return key in unsupportedEasingFunctions;
|
|
78
|
-
}
|
|
79
|
-
class AcceleratedAnimation extends BaseAnimation {
|
|
80
|
-
constructor(options) {
|
|
81
|
-
super(options);
|
|
82
|
-
const { name, motionValue, element, keyframes } = this.options;
|
|
83
|
-
this.resolver = new DOMKeyframesResolver(keyframes, (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe), name, motionValue, element);
|
|
84
|
-
this.resolver.scheduleResolve();
|
|
85
|
-
}
|
|
86
|
-
initPlayback(keyframes, finalKeyframe) {
|
|
87
|
-
let { duration = 300, times, ease, type, motionValue, name, startTime, } = this.options;
|
|
88
|
-
/**
|
|
89
|
-
* If element has since been unmounted, return false to indicate
|
|
90
|
-
* the animation failed to initialised.
|
|
91
|
-
*/
|
|
92
|
-
if (!motionValue.owner || !motionValue.owner.current) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* If the user has provided an easing function name that isn't supported
|
|
97
|
-
* by WAAPI (like "anticipate"), we need to provide the corressponding
|
|
98
|
-
* function. This will later get converted to a linear() easing function.
|
|
99
|
-
*/
|
|
100
|
-
if (typeof ease === "string" &&
|
|
101
|
-
supportsLinearEasing() &&
|
|
102
|
-
isUnsupportedEase(ease)) {
|
|
103
|
-
ease = unsupportedEasingFunctions[ease];
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* If this animation needs pre-generated keyframes then generate.
|
|
107
|
-
*/
|
|
108
|
-
if (requiresPregeneratedKeyframes(this.options)) {
|
|
109
|
-
const { onComplete, onUpdate, motionValue, element, ...options } = this.options;
|
|
110
|
-
const pregeneratedAnimation = pregenerateKeyframes(keyframes, options);
|
|
111
|
-
keyframes = pregeneratedAnimation.keyframes;
|
|
112
|
-
// If this is a very short animation, ensure we have
|
|
113
|
-
// at least two keyframes to animate between as older browsers
|
|
114
|
-
// can't animate between a single keyframe.
|
|
115
|
-
if (keyframes.length === 1) {
|
|
116
|
-
keyframes[1] = keyframes[0];
|
|
117
|
-
}
|
|
118
|
-
duration = pregeneratedAnimation.duration;
|
|
119
|
-
times = pregeneratedAnimation.times;
|
|
120
|
-
ease = pregeneratedAnimation.ease;
|
|
121
|
-
type = "keyframes";
|
|
122
|
-
}
|
|
123
|
-
const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
|
|
124
|
-
// Override the browser calculated startTime with one synchronised to other JS
|
|
125
|
-
// and WAAPI animations starting this event loop.
|
|
126
|
-
animation.startTime = startTime ?? this.calcStartTime();
|
|
127
|
-
if (this.pendingTimeline) {
|
|
128
|
-
attachTimeline(animation, this.pendingTimeline);
|
|
129
|
-
this.pendingTimeline = undefined;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
/**
|
|
133
|
-
* Prefer the `onfinish` prop as it's more widely supported than
|
|
134
|
-
* the `finished` promise.
|
|
135
|
-
*
|
|
136
|
-
* Here, we synchronously set the provided MotionValue to the end
|
|
137
|
-
* keyframe. If we didn't, when the WAAPI animation is finished it would
|
|
138
|
-
* be removed from the element which would then revert to its old styles.
|
|
139
|
-
*/
|
|
140
|
-
animation.onfinish = () => {
|
|
141
|
-
const { onComplete } = this.options;
|
|
142
|
-
motionValue.set(getFinalKeyframe(keyframes, this.options, finalKeyframe));
|
|
143
|
-
onComplete && onComplete();
|
|
144
|
-
this.cancel();
|
|
145
|
-
this.resolveFinishedPromise();
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
animation,
|
|
150
|
-
duration,
|
|
151
|
-
times,
|
|
152
|
-
type,
|
|
153
|
-
ease,
|
|
154
|
-
keyframes: keyframes,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
get duration() {
|
|
158
|
-
const { resolved } = this;
|
|
159
|
-
if (!resolved)
|
|
160
|
-
return 0;
|
|
161
|
-
const { duration } = resolved;
|
|
162
|
-
return millisecondsToSeconds(duration);
|
|
163
|
-
}
|
|
164
|
-
get time() {
|
|
165
|
-
const { resolved } = this;
|
|
166
|
-
if (!resolved)
|
|
167
|
-
return 0;
|
|
168
|
-
const { animation } = resolved;
|
|
169
|
-
return millisecondsToSeconds(animation.currentTime || 0);
|
|
170
|
-
}
|
|
171
|
-
set time(newTime) {
|
|
172
|
-
const { resolved } = this;
|
|
173
|
-
if (!resolved)
|
|
174
|
-
return;
|
|
175
|
-
const { animation } = resolved;
|
|
176
|
-
animation.currentTime = secondsToMilliseconds(newTime);
|
|
177
|
-
}
|
|
178
|
-
get speed() {
|
|
179
|
-
const { resolved } = this;
|
|
180
|
-
if (!resolved)
|
|
181
|
-
return 1;
|
|
182
|
-
const { animation } = resolved;
|
|
183
|
-
return animation.playbackRate;
|
|
184
|
-
}
|
|
185
|
-
get finished() {
|
|
186
|
-
return this.resolved.animation.finished;
|
|
187
|
-
}
|
|
188
|
-
set speed(newSpeed) {
|
|
189
|
-
const { resolved } = this;
|
|
190
|
-
if (!resolved)
|
|
191
|
-
return;
|
|
192
|
-
const { animation } = resolved;
|
|
193
|
-
animation.playbackRate = newSpeed;
|
|
194
|
-
}
|
|
195
|
-
get state() {
|
|
196
|
-
const { resolved } = this;
|
|
197
|
-
if (!resolved)
|
|
198
|
-
return "idle";
|
|
199
|
-
const { animation } = resolved;
|
|
200
|
-
return animation.playState;
|
|
201
|
-
}
|
|
202
|
-
get startTime() {
|
|
203
|
-
const { resolved } = this;
|
|
204
|
-
if (!resolved)
|
|
205
|
-
return null;
|
|
206
|
-
const { animation } = resolved;
|
|
207
|
-
// Coerce to number as TypeScript incorrectly types this
|
|
208
|
-
// as CSSNumberish
|
|
209
|
-
return animation.startTime;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Replace the default DocumentTimeline with another AnimationTimeline.
|
|
213
|
-
* Currently used for scroll animations.
|
|
214
|
-
*/
|
|
215
|
-
attachTimeline(timeline) {
|
|
216
|
-
if (!this._resolved) {
|
|
217
|
-
this.pendingTimeline = timeline;
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
const { resolved } = this;
|
|
221
|
-
if (!resolved)
|
|
222
|
-
return noop;
|
|
223
|
-
const { animation } = resolved;
|
|
224
|
-
attachTimeline(animation, timeline);
|
|
225
|
-
}
|
|
226
|
-
return noop;
|
|
227
|
-
}
|
|
228
|
-
play() {
|
|
229
|
-
if (this.isStopped)
|
|
230
|
-
return;
|
|
231
|
-
const { resolved } = this;
|
|
232
|
-
if (!resolved)
|
|
233
|
-
return;
|
|
234
|
-
const { animation } = resolved;
|
|
235
|
-
if (animation.playState === "finished") {
|
|
236
|
-
this.updateFinishedPromise();
|
|
237
|
-
}
|
|
238
|
-
animation.play();
|
|
239
|
-
}
|
|
240
|
-
pause() {
|
|
241
|
-
const { resolved } = this;
|
|
242
|
-
if (!resolved)
|
|
243
|
-
return;
|
|
244
|
-
const { animation } = resolved;
|
|
245
|
-
animation.pause();
|
|
246
|
-
}
|
|
247
|
-
stop() {
|
|
248
|
-
this.resolver.cancel();
|
|
249
|
-
this.isStopped = true;
|
|
250
|
-
if (this.state === "idle")
|
|
251
|
-
return;
|
|
252
|
-
this.resolveFinishedPromise();
|
|
253
|
-
this.updateFinishedPromise();
|
|
254
|
-
const { resolved } = this;
|
|
255
|
-
if (!resolved)
|
|
256
|
-
return;
|
|
257
|
-
const { animation, keyframes, duration, type, ease, times } = resolved;
|
|
258
|
-
if (animation.playState === "idle" ||
|
|
259
|
-
animation.playState === "finished") {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* WAAPI doesn't natively have any interruption capabilities.
|
|
264
|
-
*
|
|
265
|
-
* Rather than read commited styles back out of the DOM, we can
|
|
266
|
-
* create a renderless JS animation and sample it twice to calculate
|
|
267
|
-
* its current value, "previous" value, and therefore allow
|
|
268
|
-
* Motion to calculate velocity for any subsequent animation.
|
|
269
|
-
*/
|
|
270
|
-
if (this.time) {
|
|
271
|
-
const { motionValue, onUpdate, onComplete, element, ...options } = this.options;
|
|
272
|
-
const sampleAnimation = new MainThreadAnimation({
|
|
273
|
-
...options,
|
|
274
|
-
keyframes,
|
|
275
|
-
duration,
|
|
276
|
-
type,
|
|
277
|
-
ease,
|
|
278
|
-
times,
|
|
279
|
-
isGenerator: true,
|
|
280
|
-
});
|
|
281
|
-
const sampleTime = secondsToMilliseconds(this.time);
|
|
282
|
-
motionValue.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
|
|
283
|
-
}
|
|
284
|
-
const { onStop } = this.options;
|
|
285
|
-
onStop && onStop();
|
|
286
|
-
this.cancel();
|
|
287
|
-
}
|
|
288
|
-
complete() {
|
|
289
|
-
const { resolved } = this;
|
|
290
|
-
if (!resolved)
|
|
291
|
-
return;
|
|
292
|
-
resolved.animation.finish();
|
|
293
|
-
}
|
|
294
|
-
cancel() {
|
|
295
|
-
const { resolved } = this;
|
|
296
|
-
if (!resolved)
|
|
297
|
-
return;
|
|
298
|
-
resolved.animation.cancel();
|
|
299
|
-
}
|
|
300
|
-
static supports(options) {
|
|
301
|
-
const { motionValue, name, repeatDelay, repeatType, damping, type } = options;
|
|
302
|
-
if (!motionValue ||
|
|
303
|
-
!motionValue.owner ||
|
|
304
|
-
!(motionValue.owner.current instanceof HTMLElement)) {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
const { onUpdate, transformTemplate } = motionValue.owner.getProps();
|
|
308
|
-
return (supportsWaapi() &&
|
|
309
|
-
name &&
|
|
310
|
-
acceleratedValues.has(name) &&
|
|
311
|
-
(name !== "transform" || !transformTemplate) &&
|
|
312
|
-
/**
|
|
313
|
-
* If we're outputting values to onUpdate then we can't use WAAPI as there's
|
|
314
|
-
* no way to read the value from WAAPI every frame.
|
|
315
|
-
*/
|
|
316
|
-
!onUpdate &&
|
|
317
|
-
!repeatDelay &&
|
|
318
|
-
repeatType !== "mirror" &&
|
|
319
|
-
damping !== 0 &&
|
|
320
|
-
type !== "inertia");
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export { AcceleratedAnimation };
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { flushKeyframeResolvers } from '../../render/utils/KeyframesResolver.mjs';
|
|
2
|
-
import { instantAnimationState } from '../../utils/use-instant-transition-state.mjs';
|
|
3
|
-
import { canAnimate } from './utils/can-animate.mjs';
|
|
4
|
-
import { getFinalKeyframe } from './waapi/utils/get-final-keyframe.mjs';
|
|
5
|
-
import { time } from '../../../../../motion-dom/dist/es/frameloop/sync-time.mjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Maximum time allowed between an animation being created and it being
|
|
9
|
-
* resolved for us to use the latter as the start time.
|
|
10
|
-
*
|
|
11
|
-
* This is to ensure that while we prefer to "start" an animation as soon
|
|
12
|
-
* as it's triggered, we also want to avoid a visual jump if there's a big delay
|
|
13
|
-
* between these two moments.
|
|
14
|
-
*/
|
|
15
|
-
const MAX_RESOLVE_DELAY = 40;
|
|
16
|
-
class BaseAnimation {
|
|
17
|
-
constructor({ autoplay = true, delay = 0, type = "keyframes", repeat = 0, repeatDelay = 0, repeatType = "loop", ...options }) {
|
|
18
|
-
// Track whether the animation has been stopped. Stopped animations won't restart.
|
|
19
|
-
this.isStopped = false;
|
|
20
|
-
this.hasAttemptedResolve = false;
|
|
21
|
-
this.createdAt = time.now();
|
|
22
|
-
this.options = {
|
|
23
|
-
autoplay,
|
|
24
|
-
delay,
|
|
25
|
-
type,
|
|
26
|
-
repeat,
|
|
27
|
-
repeatDelay,
|
|
28
|
-
repeatType,
|
|
29
|
-
...options,
|
|
30
|
-
};
|
|
31
|
-
this.updateFinishedPromise();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* This method uses the createdAt and resolvedAt to calculate the
|
|
35
|
-
* animation startTime. *Ideally*, we would use the createdAt time as t=0
|
|
36
|
-
* as the following frame would then be the first frame of the animation in
|
|
37
|
-
* progress, which would feel snappier.
|
|
38
|
-
*
|
|
39
|
-
* However, if there's a delay (main thread work) between the creation of
|
|
40
|
-
* the animation and the first commited frame, we prefer to use resolvedAt
|
|
41
|
-
* to avoid a sudden jump into the animation.
|
|
42
|
-
*/
|
|
43
|
-
calcStartTime() {
|
|
44
|
-
if (!this.resolvedAt)
|
|
45
|
-
return this.createdAt;
|
|
46
|
-
return this.resolvedAt - this.createdAt > MAX_RESOLVE_DELAY
|
|
47
|
-
? this.resolvedAt
|
|
48
|
-
: this.createdAt;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A getter for resolved data. If keyframes are not yet resolved, accessing
|
|
52
|
-
* this.resolved will synchronously flush all pending keyframe resolvers.
|
|
53
|
-
* This is a deoptimisation, but at its worst still batches read/writes.
|
|
54
|
-
*/
|
|
55
|
-
get resolved() {
|
|
56
|
-
if (!this._resolved && !this.hasAttemptedResolve) {
|
|
57
|
-
flushKeyframeResolvers();
|
|
58
|
-
}
|
|
59
|
-
return this._resolved;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* A method to be called when the keyframes resolver completes. This method
|
|
63
|
-
* will check if its possible to run the animation and, if not, skip it.
|
|
64
|
-
* Otherwise, it will call initPlayback on the implementing class.
|
|
65
|
-
*/
|
|
66
|
-
onKeyframesResolved(keyframes, finalKeyframe) {
|
|
67
|
-
this.resolvedAt = time.now();
|
|
68
|
-
this.hasAttemptedResolve = true;
|
|
69
|
-
const { name, type, velocity, delay, onComplete, onUpdate, isGenerator, } = this.options;
|
|
70
|
-
/**
|
|
71
|
-
* If we can't animate this value with the resolved keyframes
|
|
72
|
-
* then we should complete it immediately.
|
|
73
|
-
*/
|
|
74
|
-
if (!isGenerator && !canAnimate(keyframes, name, type, velocity)) {
|
|
75
|
-
// Finish immediately
|
|
76
|
-
if (instantAnimationState.current || !delay) {
|
|
77
|
-
onUpdate &&
|
|
78
|
-
onUpdate(getFinalKeyframe(keyframes, this.options, finalKeyframe));
|
|
79
|
-
onComplete && onComplete();
|
|
80
|
-
this.resolveFinishedPromise();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// Finish after a delay
|
|
84
|
-
else {
|
|
85
|
-
this.options.duration = 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const resolvedAnimation = this.initPlayback(keyframes, finalKeyframe);
|
|
89
|
-
if (resolvedAnimation === false)
|
|
90
|
-
return;
|
|
91
|
-
this._resolved = {
|
|
92
|
-
keyframes,
|
|
93
|
-
finalKeyframe,
|
|
94
|
-
...resolvedAnimation,
|
|
95
|
-
};
|
|
96
|
-
this.onPostResolved();
|
|
97
|
-
}
|
|
98
|
-
onPostResolved() { }
|
|
99
|
-
/**
|
|
100
|
-
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
101
|
-
* resolves when the animation finishes at all but in a future update could/should
|
|
102
|
-
* reject if its cancels.
|
|
103
|
-
*/
|
|
104
|
-
then(resolve, reject) {
|
|
105
|
-
return this.currentFinishedPromise.then(resolve, reject);
|
|
106
|
-
}
|
|
107
|
-
flatten() {
|
|
108
|
-
if (!this.options.allowFlatten)
|
|
109
|
-
return;
|
|
110
|
-
this.options.type = "keyframes";
|
|
111
|
-
this.options.ease = "linear";
|
|
112
|
-
}
|
|
113
|
-
updateFinishedPromise() {
|
|
114
|
-
this.currentFinishedPromise = new Promise((resolve) => {
|
|
115
|
-
this.resolveFinishedPromise = resolve;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export { BaseAnimation };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { alpha } from '../../../value/types/numbers/index.mjs';
|
|
2
|
-
import { px } from '../../../value/types/numbers/units.mjs';
|
|
3
|
-
import { browserNumberValueTypes } from './number-browser.mjs';
|
|
4
|
-
import { transformValueTypes } from './transform.mjs';
|
|
5
|
-
import { int } from './type-int.mjs';
|
|
6
|
-
|
|
7
|
-
const numberValueTypes = {
|
|
8
|
-
...browserNumberValueTypes,
|
|
9
|
-
...transformValueTypes,
|
|
10
|
-
zIndex: int,
|
|
11
|
-
size: px,
|
|
12
|
-
// SVG
|
|
13
|
-
fillOpacity: alpha,
|
|
14
|
-
strokeOpacity: alpha,
|
|
15
|
-
numOctaves: int,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { numberValueTypes };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { style } from '../../render/dom/style.mjs';
|
|
2
|
-
import { supportsPartialKeyframes } from '../waapi/supports/partial-keyframes.mjs';
|
|
3
|
-
import { pxValues } from '../waapi/utils/px-values.mjs';
|
|
4
|
-
|
|
5
|
-
function hydrateKeyframes(element, name, keyframes, pseudoElement) {
|
|
6
|
-
if (!Array.isArray(keyframes)) {
|
|
7
|
-
keyframes = [keyframes];
|
|
8
|
-
}
|
|
9
|
-
for (let i = 0; i < keyframes.length; i++) {
|
|
10
|
-
if (keyframes[i] === null) {
|
|
11
|
-
keyframes[i] =
|
|
12
|
-
i === 0 && !pseudoElement
|
|
13
|
-
? style.get(element, name)
|
|
14
|
-
: keyframes[i - 1];
|
|
15
|
-
}
|
|
16
|
-
if (typeof keyframes[i] === "number" && pxValues.has(name)) {
|
|
17
|
-
keyframes[i] = keyframes[i] + "px";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (!pseudoElement && !supportsPartialKeyframes() && keyframes.length < 2) {
|
|
21
|
-
keyframes.unshift(style.get(element, name));
|
|
22
|
-
}
|
|
23
|
-
return keyframes;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { hydrateKeyframes };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const isCSSVar = (name) => name.startsWith("--");
|
|
2
|
-
const style = {
|
|
3
|
-
set: (element, name, value) => {
|
|
4
|
-
isCSSVar(name)
|
|
5
|
-
? element.style.setProperty(name, value)
|
|
6
|
-
: (element.style[name] = value);
|
|
7
|
-
},
|
|
8
|
-
get: (element, name) => {
|
|
9
|
-
return isCSSVar(name)
|
|
10
|
-
? element.style.getPropertyValue(name)
|
|
11
|
-
: element.style[name];
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { style };
|
|
File without changes
|
/package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/defaults.mjs
RENAMED
|
File without changes
|
/package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/velocity.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/single-color-regex.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/es/{motion-dom/dist/es → motion-utils/dist/es/easing}/utils/is-bezier-definition.mjs
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/is-numerical-string.mjs
RENAMED
|
File without changes
|
/package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/is-zero-value-string.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|