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,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo, useRef, useState, useContext } from 'react';
|
|
4
|
-
import { PresenceChild } from './PresenceChild.mjs';
|
|
5
4
|
import { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';
|
|
6
|
-
import { invariant } from '../../utils/errors.mjs';
|
|
7
5
|
import { useConstant } from '../../utils/use-constant.mjs';
|
|
6
|
+
import { PresenceChild } from './PresenceChild.mjs';
|
|
7
|
+
import { usePresence } from './use-presence.mjs';
|
|
8
8
|
import { onlyElements, getChildKey } from './utils.mjs';
|
|
9
9
|
import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
|
|
10
10
|
|
|
@@ -41,8 +41,8 @@ import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs
|
|
|
41
41
|
*
|
|
42
42
|
* @public
|
|
43
43
|
*/
|
|
44
|
-
const AnimatePresence = ({ children,
|
|
45
|
-
|
|
44
|
+
const AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false, }) => {
|
|
45
|
+
const [isParentPresent, safeToRemove] = usePresence(propagate);
|
|
46
46
|
/**
|
|
47
47
|
* Filter any children that aren't ReactElements. We can only track components
|
|
48
48
|
* between renders with a props.key.
|
|
@@ -52,7 +52,7 @@ const AnimatePresence = ({ children, exitBeforeEnter, custom, initial = true, on
|
|
|
52
52
|
* Track the keys of the currently rendered children. This is used to
|
|
53
53
|
* determine which children are exiting.
|
|
54
54
|
*/
|
|
55
|
-
const presentKeys = presentChildren.map(getChildKey);
|
|
55
|
+
const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);
|
|
56
56
|
/**
|
|
57
57
|
* If `initial={false}` we only want to pass this to components in the first render.
|
|
58
58
|
*/
|
|
@@ -134,8 +134,10 @@ const AnimatePresence = ({ children, exitBeforeEnter, custom, initial = true, on
|
|
|
134
134
|
const { forceRender } = useContext(LayoutGroupContext);
|
|
135
135
|
return (jsx(Fragment, { children: renderedChildren.map((child) => {
|
|
136
136
|
const key = getChildKey(child);
|
|
137
|
-
const isPresent =
|
|
138
|
-
|
|
137
|
+
const isPresent = propagate && !isParentPresent
|
|
138
|
+
? false
|
|
139
|
+
: presentChildren === renderedChildren ||
|
|
140
|
+
presentKeys.includes(key);
|
|
139
141
|
const onExit = () => {
|
|
140
142
|
if (exitComplete.has(key)) {
|
|
141
143
|
exitComplete.set(key, true);
|
|
@@ -151,6 +153,7 @@ const AnimatePresence = ({ children, exitBeforeEnter, custom, initial = true, on
|
|
|
151
153
|
if (isEveryExitComplete) {
|
|
152
154
|
forceRender === null || forceRender === void 0 ? void 0 : forceRender();
|
|
153
155
|
setRenderedChildren(pendingPresentChildren.current);
|
|
156
|
+
propagate && (safeToRemove === null || safeToRemove === void 0 ? void 0 : safeToRemove());
|
|
154
157
|
onExitComplete && onExitComplete();
|
|
155
158
|
}
|
|
156
159
|
};
|
|
@@ -24,7 +24,7 @@ import { PresenceContext } from '../../context/PresenceContext.mjs';
|
|
|
24
24
|
*
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
function usePresence() {
|
|
27
|
+
function usePresence(subscribe = true) {
|
|
28
28
|
const context = useContext(PresenceContext);
|
|
29
29
|
if (context === null)
|
|
30
30
|
return [true, null];
|
|
@@ -32,8 +32,11 @@ function usePresence() {
|
|
|
32
32
|
// It's safe to call the following hooks conditionally (after an early return) because the context will always
|
|
33
33
|
// either be null or non-null for the lifespan of the component.
|
|
34
34
|
const id = useId();
|
|
35
|
-
useEffect(() =>
|
|
36
|
-
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (subscribe)
|
|
37
|
+
register(id);
|
|
38
|
+
}, [subscribe]);
|
|
39
|
+
const safeToRemove = useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);
|
|
37
40
|
return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { invariant } from '
|
|
2
|
+
import { invariant } from '../../../../motion-utils/dist/es/errors.mjs';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useConstant } from '../utils/use-constant.mjs';
|
|
5
5
|
import { LayoutGroup } from './LayoutGroup/index.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { invariant } from '
|
|
3
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
4
4
|
import { forwardRef, useRef, useEffect } from 'react';
|
|
5
5
|
import { ReorderContext } from '../../context/ReorderContext.mjs';
|
|
6
6
|
import { motion } from '../../render/components/motion/proxy.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { invariant } from '
|
|
3
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
4
4
|
import { forwardRef, useContext } from 'react';
|
|
5
5
|
import { ReorderContext } from '../../context/ReorderContext.mjs';
|
|
6
6
|
import { motion } from '../../render/components/motion/proxy.mjs';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { invariant } from '
|
|
1
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { isBezierDefinition } from '../../../../../motion-dom/dist/es/utils/is-bezier-definition.mjs';
|
|
4
|
+
import { anticipate } from '../anticipate.mjs';
|
|
5
|
+
import { backIn, backInOut, backOut } from '../back.mjs';
|
|
6
|
+
import { circIn, circInOut, circOut } from '../circ.mjs';
|
|
2
7
|
import { cubicBezier } from '../cubic-bezier.mjs';
|
|
3
|
-
import { noop } from '../../utils/noop.mjs';
|
|
4
8
|
import { easeIn, easeInOut, easeOut } from '../ease.mjs';
|
|
5
|
-
import { circIn, circInOut, circOut } from '../circ.mjs';
|
|
6
|
-
import { backIn, backInOut, backOut } from '../back.mjs';
|
|
7
|
-
import { anticipate } from '../anticipate.mjs';
|
|
8
|
-
import { isBezierDefinition } from './is-bezier-definition.mjs';
|
|
9
9
|
|
|
10
10
|
const easingLookup = {
|
|
11
11
|
linear: noop,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { isPrimaryPointer } from '../../../../motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs';
|
|
2
3
|
|
|
3
|
-
function extractEventInfo(event
|
|
4
|
+
function extractEventInfo(event) {
|
|
4
5
|
return {
|
|
5
6
|
point: {
|
|
6
|
-
x: event
|
|
7
|
-
y: event
|
|
7
|
+
x: event.pageX,
|
|
8
|
+
y: event.pageY,
|
|
8
9
|
},
|
|
9
10
|
};
|
|
10
11
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../motion-utils/dist/es/noop.mjs';
|
|
2
3
|
import { createRenderBatcher } from './batcher.mjs';
|
|
3
4
|
|
|
4
5
|
const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps, } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
|
|
@@ -63,10 +63,11 @@ function createRenderStep(runNextFrame) {
|
|
|
63
63
|
}
|
|
64
64
|
isProcessing = true;
|
|
65
65
|
[thisFrame, nextFrame] = [nextFrame, thisFrame];
|
|
66
|
-
// Clear the next frame queue
|
|
67
|
-
nextFrame.clear();
|
|
68
66
|
// Execute this frame
|
|
69
67
|
thisFrame.forEach(triggerCallback);
|
|
68
|
+
// Clear the frame so no callbacks remain. This is to avoid
|
|
69
|
+
// memory leaks should this render step not run for a while.
|
|
70
|
+
thisFrame.clear();
|
|
70
71
|
isProcessing = false;
|
|
71
72
|
if (flushNextFrame) {
|
|
72
73
|
flushNextFrame = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { invariant } from '
|
|
1
|
+
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { setDragLock } from '../../../../../motion-dom/dist/es/gestures/drag/state/set-active.mjs';
|
|
2
3
|
import { PanSession } from '../pan/PanSession.mjs';
|
|
3
|
-
import { getGlobalLock } from './utils/lock.mjs';
|
|
4
4
|
import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
5
5
|
import { addPointerEvent } from '../../events/add-pointer-event.mjs';
|
|
6
6
|
import { applyConstraints, calcRelativeConstraints, resolveDragElastic, calcViewportConstraints, rebaseAxisConstraints, calcOrigin, defaultElastic } from './utils/constraints.mjs';
|
|
@@ -25,10 +25,7 @@ const elementDragControls = new WeakMap();
|
|
|
25
25
|
// let latestPointerEvent: PointerEvent
|
|
26
26
|
class VisualElementDragControls {
|
|
27
27
|
constructor(visualElement) {
|
|
28
|
-
|
|
29
|
-
// can "capture" the drag of one or both axes.
|
|
30
|
-
// TODO: Look into moving this into pansession?
|
|
31
|
-
this.openGlobalLock = null;
|
|
28
|
+
this.openDragLock = null;
|
|
32
29
|
this.isDragging = false;
|
|
33
30
|
this.currentDirection = null;
|
|
34
31
|
this.originPoint = { x: 0, y: 0 };
|
|
@@ -56,18 +53,18 @@ class VisualElementDragControls {
|
|
|
56
53
|
// the component.
|
|
57
54
|
dragSnapToOrigin ? this.pauseAnimation() : this.stopAnimation();
|
|
58
55
|
if (snapToCursor) {
|
|
59
|
-
this.snapToCursor(extractEventInfo(event
|
|
56
|
+
this.snapToCursor(extractEventInfo(event).point);
|
|
60
57
|
}
|
|
61
58
|
};
|
|
62
59
|
const onStart = (event, info) => {
|
|
63
60
|
// Attempt to grab the global drag gesture lock - maybe make this part of PanSession
|
|
64
61
|
const { drag, dragPropagation, onDragStart } = this.getProps();
|
|
65
62
|
if (drag && !dragPropagation) {
|
|
66
|
-
if (this.
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
63
|
+
if (this.openDragLock)
|
|
64
|
+
this.openDragLock();
|
|
65
|
+
this.openDragLock = setDragLock(drag);
|
|
69
66
|
// If we don 't have the lock, don't start dragging
|
|
70
|
-
if (!this.
|
|
67
|
+
if (!this.openDragLock)
|
|
71
68
|
return;
|
|
72
69
|
}
|
|
73
70
|
this.isDragging = true;
|
|
@@ -109,7 +106,7 @@ class VisualElementDragControls {
|
|
|
109
106
|
// latestPointerEvent = event
|
|
110
107
|
const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();
|
|
111
108
|
// If we didn't successfully receive the gesture lock, early return.
|
|
112
|
-
if (!dragPropagation && !this.
|
|
109
|
+
if (!dragPropagation && !this.openDragLock)
|
|
113
110
|
return;
|
|
114
111
|
const { offset } = info;
|
|
115
112
|
// Attempt to detect drag direction if directionLock is true
|
|
@@ -177,9 +174,9 @@ class VisualElementDragControls {
|
|
|
177
174
|
this.panSession && this.panSession.end();
|
|
178
175
|
this.panSession = undefined;
|
|
179
176
|
const { dragPropagation } = this.getProps();
|
|
180
|
-
if (!dragPropagation && this.
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
177
|
+
if (!dragPropagation && this.openDragLock) {
|
|
178
|
+
this.openDragLock();
|
|
179
|
+
this.openDragLock = null;
|
|
183
180
|
}
|
|
184
181
|
animationState && animationState.setActive("whileDrag", false);
|
|
185
182
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Feature } from '../../motion/features/Feature.mjs';
|
|
2
|
-
import
|
|
2
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
3
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
4
|
import { VisualElementDragControls } from './VisualElementDragControls.mjs';
|
|
4
5
|
|
|
5
6
|
class DragGesture extends Feature {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { progress } from '../../../../../../motion-utils/dist/es/progress.mjs';
|
|
2
3
|
import { calcLength } from '../../../projection/geometry/delta-calc.mjs';
|
|
3
4
|
import { clamp } from '../../../utils/clamp.mjs';
|
|
4
5
|
import { mixNumber } from '../../../utils/mix/number.mjs';
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { hover } from '../../../../motion-dom/dist/es/gestures/hover.mjs';
|
|
3
|
+
import { extractEventInfo } from '../events/event-info.mjs';
|
|
4
4
|
import { Feature } from '../motion/features/Feature.mjs';
|
|
5
5
|
import { frame } from '../frameloop/frame.mjs';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const callback = props[callbackName];
|
|
18
|
-
if (callback) {
|
|
19
|
-
frame.postRender(() => callback(event, info));
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
return addPointerEvent(node.current, eventName, handleEvent, {
|
|
23
|
-
passive: !node.getProps()[callbackName],
|
|
24
|
-
});
|
|
7
|
+
function handleHoverEvent(node, event, lifecycle) {
|
|
8
|
+
const { props } = node;
|
|
9
|
+
if (node.animationState && props.whileHover) {
|
|
10
|
+
node.animationState.setActive("whileHover", lifecycle === "Start");
|
|
11
|
+
}
|
|
12
|
+
const eventName = ("onHover" + lifecycle);
|
|
13
|
+
const callback = props[eventName];
|
|
14
|
+
if (callback) {
|
|
15
|
+
frame.postRender(() => callback(event, extractEventInfo(event)));
|
|
16
|
+
}
|
|
25
17
|
}
|
|
26
18
|
class HoverGesture extends Feature {
|
|
27
19
|
mount() {
|
|
28
|
-
|
|
20
|
+
const { current } = this.node;
|
|
21
|
+
if (!current)
|
|
22
|
+
return;
|
|
23
|
+
this.unmount = hover(current, (_element, startEvent) => {
|
|
24
|
+
handleHoverEvent(this.node, startEvent, "Start");
|
|
25
|
+
return (endEvent) => handleHoverEvent(this.node, endEvent, "End");
|
|
26
|
+
});
|
|
29
27
|
}
|
|
30
28
|
unmount() { }
|
|
31
29
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { secondsToMilliseconds, millisecondsToSeconds } from '
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { secondsToMilliseconds, millisecondsToSeconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { isPrimaryPointer } from '../../../../../motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs';
|
|
3
4
|
import { addPointerEvent } from '../../events/add-pointer-event.mjs';
|
|
4
|
-
import {
|
|
5
|
+
import { extractEventInfo } from '../../events/event-info.mjs';
|
|
5
6
|
import { distance2D } from '../../utils/distance.mjs';
|
|
6
|
-
import {
|
|
7
|
+
import { pipe } from '../../utils/pipe.mjs';
|
|
7
8
|
import { frame, cancelFrame, frameData } from '../../frameloop/frame.mjs';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
13
|
class PanSession {
|
|
13
|
-
constructor(event, handlers, { transformPagePoint, contextWindow, dragSnapToOrigin = false } = {}) {
|
|
14
|
+
constructor(event, handlers, { transformPagePoint, contextWindow, dragSnapToOrigin = false, } = {}) {
|
|
14
15
|
/**
|
|
15
16
|
* @internal
|
|
16
17
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { PanSession } from './PanSession.mjs';
|
|
2
2
|
import { addPointerEvent } from '../../events/add-pointer-event.mjs';
|
|
3
3
|
import { Feature } from '../../motion/features/Feature.mjs';
|
|
4
|
-
import
|
|
4
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
5
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
5
6
|
import { getContextWindow } from '../../utils/get-context-window.mjs';
|
|
6
7
|
import { frame } from '../../frameloop/frame.mjs';
|
|
7
8
|
|
|
@@ -1,130 +1,31 @@
|
|
|
1
|
+
import '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { press } from '../../../../motion-dom/dist/es/gestures/press/index.mjs';
|
|
1
3
|
import { extractEventInfo } from '../events/event-info.mjs';
|
|
2
|
-
import { addDomEvent } from '../events/add-dom-event.mjs';
|
|
3
|
-
import { addPointerEvent } from '../events/add-pointer-event.mjs';
|
|
4
4
|
import { Feature } from '../motion/features/Feature.mjs';
|
|
5
|
-
import { pipe } from '../utils/pipe.mjs';
|
|
6
|
-
import { isDragActive } from './drag/utils/lock.mjs';
|
|
7
|
-
import { isNodeOrChild } from './utils/is-node-or-child.mjs';
|
|
8
|
-
import { noop } from '../utils/noop.mjs';
|
|
9
5
|
import { frame } from '../frameloop/frame.mjs';
|
|
10
6
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
handler(syntheticPointerEvent, extractEventInfo(syntheticPointerEvent));
|
|
16
|
-
}
|
|
17
|
-
class PressGesture extends Feature {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.removeStartListeners = noop;
|
|
21
|
-
this.removeEndListeners = noop;
|
|
22
|
-
this.removeAccessibleListeners = noop;
|
|
23
|
-
this.startPointerPress = (startEvent, startInfo) => {
|
|
24
|
-
if (this.isPressing)
|
|
25
|
-
return;
|
|
26
|
-
this.removeEndListeners();
|
|
27
|
-
const props = this.node.getProps();
|
|
28
|
-
const endPointerPress = (endEvent, endInfo) => {
|
|
29
|
-
if (!this.checkPressEnd())
|
|
30
|
-
return;
|
|
31
|
-
const { onTap, onTapCancel, globalTapTarget } = this.node.getProps();
|
|
32
|
-
/**
|
|
33
|
-
* We only count this as a tap gesture if the event.target is the same
|
|
34
|
-
* as, or a child of, this component's element
|
|
35
|
-
*/
|
|
36
|
-
const handler = !globalTapTarget &&
|
|
37
|
-
!isNodeOrChild(this.node.current, endEvent.target)
|
|
38
|
-
? onTapCancel
|
|
39
|
-
: onTap;
|
|
40
|
-
if (handler) {
|
|
41
|
-
frame.update(() => handler(endEvent, endInfo));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const removePointerUpListener = addPointerEvent(window, "pointerup", endPointerPress, {
|
|
45
|
-
passive: !(props.onTap || props["onPointerUp"]),
|
|
46
|
-
});
|
|
47
|
-
const removePointerCancelListener = addPointerEvent(window, "pointercancel", (cancelEvent, cancelInfo) => this.cancelPress(cancelEvent, cancelInfo), {
|
|
48
|
-
passive: !(props.onTapCancel ||
|
|
49
|
-
props["onPointerCancel"]),
|
|
50
|
-
});
|
|
51
|
-
this.removeEndListeners = pipe(removePointerUpListener, removePointerCancelListener);
|
|
52
|
-
this.startPress(startEvent, startInfo);
|
|
53
|
-
};
|
|
54
|
-
this.startAccessiblePress = () => {
|
|
55
|
-
const handleKeydown = (keydownEvent) => {
|
|
56
|
-
if (keydownEvent.key !== "Enter" || this.isPressing)
|
|
57
|
-
return;
|
|
58
|
-
const handleKeyup = (keyupEvent) => {
|
|
59
|
-
if (keyupEvent.key !== "Enter" || !this.checkPressEnd())
|
|
60
|
-
return;
|
|
61
|
-
fireSyntheticPointerEvent("up", (event, info) => {
|
|
62
|
-
const { onTap } = this.node.getProps();
|
|
63
|
-
if (onTap) {
|
|
64
|
-
frame.postRender(() => onTap(event, info));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
this.removeEndListeners();
|
|
69
|
-
this.removeEndListeners = addDomEvent(this.node.current, "keyup", handleKeyup);
|
|
70
|
-
fireSyntheticPointerEvent("down", (event, info) => {
|
|
71
|
-
this.startPress(event, info);
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
const removeKeydownListener = addDomEvent(this.node.current, "keydown", handleKeydown);
|
|
75
|
-
const handleBlur = () => {
|
|
76
|
-
if (!this.isPressing)
|
|
77
|
-
return;
|
|
78
|
-
fireSyntheticPointerEvent("cancel", (cancelEvent, cancelInfo) => this.cancelPress(cancelEvent, cancelInfo));
|
|
79
|
-
};
|
|
80
|
-
const removeBlurListener = addDomEvent(this.node.current, "blur", handleBlur);
|
|
81
|
-
this.removeAccessibleListeners = pipe(removeKeydownListener, removeBlurListener);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
startPress(event, info) {
|
|
85
|
-
this.isPressing = true;
|
|
86
|
-
const { onTapStart, whileTap } = this.node.getProps();
|
|
87
|
-
/**
|
|
88
|
-
* Ensure we trigger animations before firing event callback
|
|
89
|
-
*/
|
|
90
|
-
if (whileTap && this.node.animationState) {
|
|
91
|
-
this.node.animationState.setActive("whileTap", true);
|
|
92
|
-
}
|
|
93
|
-
if (onTapStart) {
|
|
94
|
-
frame.postRender(() => onTapStart(event, info));
|
|
95
|
-
}
|
|
7
|
+
function handlePressEvent(node, event, lifecycle) {
|
|
8
|
+
const { props } = node;
|
|
9
|
+
if (node.animationState && props.whileTap) {
|
|
10
|
+
node.animationState.setActive("whileTap", lifecycle === "Start");
|
|
96
11
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (props.whileTap && this.node.animationState) {
|
|
102
|
-
this.node.animationState.setActive("whileTap", false);
|
|
103
|
-
}
|
|
104
|
-
return !isDragActive();
|
|
105
|
-
}
|
|
106
|
-
cancelPress(event, info) {
|
|
107
|
-
if (!this.checkPressEnd())
|
|
108
|
-
return;
|
|
109
|
-
const { onTapCancel } = this.node.getProps();
|
|
110
|
-
if (onTapCancel) {
|
|
111
|
-
frame.postRender(() => onTapCancel(event, info));
|
|
112
|
-
}
|
|
12
|
+
const eventName = ("onTap" + (lifecycle === "End" ? "" : lifecycle));
|
|
13
|
+
const callback = props[eventName];
|
|
14
|
+
if (callback) {
|
|
15
|
+
frame.postRender(() => callback(event, extractEventInfo(event)));
|
|
113
16
|
}
|
|
17
|
+
}
|
|
18
|
+
class PressGesture extends Feature {
|
|
114
19
|
mount() {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.
|
|
122
|
-
}
|
|
123
|
-
unmount() {
|
|
124
|
-
this.removeStartListeners();
|
|
125
|
-
this.removeEndListeners();
|
|
126
|
-
this.removeAccessibleListeners();
|
|
20
|
+
const { current } = this.node;
|
|
21
|
+
if (!current)
|
|
22
|
+
return;
|
|
23
|
+
this.unmount = press(current, (_element, startEvent) => {
|
|
24
|
+
handlePressEvent(this.node, startEvent, "Start");
|
|
25
|
+
return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
|
|
26
|
+
}, { useGlobalTarget: this.node.props.globalTapTarget });
|
|
127
27
|
}
|
|
28
|
+
unmount() { }
|
|
128
29
|
}
|
|
129
30
|
|
|
130
31
|
export { PressGesture };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { warning, invariant } from '../../../../motion-utils/dist/es/errors.mjs';
|
|
3
4
|
import { forwardRef, useContext } from 'react';
|
|
5
|
+
import { LayoutGroupContext } from '../context/LayoutGroupContext.mjs';
|
|
6
|
+
import { LazyContext } from '../context/LazyContext.mjs';
|
|
4
7
|
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
5
8
|
import { MotionContext } from '../context/MotionContext/index.mjs';
|
|
6
|
-
import { useVisualElement } from './utils/use-visual-element.mjs';
|
|
7
|
-
import { useMotionRef } from './utils/use-motion-ref.mjs';
|
|
8
9
|
import { useCreateMotionContext } from '../context/MotionContext/create.mjs';
|
|
9
|
-
import { loadFeatures } from './features/load-features.mjs';
|
|
10
10
|
import { isBrowser } from '../utils/is-browser.mjs';
|
|
11
|
-
import { LayoutGroupContext } from '../context/LayoutGroupContext.mjs';
|
|
12
|
-
import { LazyContext } from '../context/LazyContext.mjs';
|
|
13
|
-
import { motionComponentSymbol } from './utils/symbol.mjs';
|
|
14
|
-
import { warning, invariant } from '../utils/errors.mjs';
|
|
15
11
|
import { featureDefinitions } from './features/definitions.mjs';
|
|
12
|
+
import { loadFeatures } from './features/load-features.mjs';
|
|
13
|
+
import { motionComponentSymbol } from './utils/symbol.mjs';
|
|
14
|
+
import { useMotionRef } from './utils/use-motion-ref.mjs';
|
|
15
|
+
import { useVisualElement } from './utils/use-visual-element.mjs';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Create a `motion` component.
|
|
@@ -24,6 +24,7 @@ import { featureDefinitions } from './features/definitions.mjs';
|
|
|
24
24
|
* component "offline", or outside the React render cycle.
|
|
25
25
|
*/
|
|
26
26
|
function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
|
|
27
|
+
var _a, _b;
|
|
27
28
|
preloadedFeatures && loadFeatures(preloadedFeatures);
|
|
28
29
|
function MotionComponent(props, externalRef) {
|
|
29
30
|
/**
|
|
@@ -57,6 +58,9 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
|
|
|
57
58
|
*/
|
|
58
59
|
return (jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement)] }));
|
|
59
60
|
}
|
|
61
|
+
MotionComponent.displayName = `motion.${typeof Component === "string"
|
|
62
|
+
? Component
|
|
63
|
+
: `create(${(_b = (_a = Component.displayName) !== null && _a !== void 0 ? _a : Component.name) !== null && _b !== void 0 ? _b : ""})`}`;
|
|
60
64
|
const ForwardRefMotionComponent = forwardRef(MotionComponent);
|
|
61
65
|
ForwardRefMotionComponent[motionComponentSymbol] = Component;
|
|
62
66
|
return ForwardRefMotionComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scaleCorrectors } from '../../projection/styles/scale-correction.mjs';
|
|
2
|
-
import { transformProps } from '../../render/html/utils/transform.mjs';
|
|
2
|
+
import { transformProps } from '../../render/html/utils/keys-transform.mjs';
|
|
3
3
|
|
|
4
4
|
function isForcedMotionValue(key, { layout, layoutId }) {
|
|
5
5
|
return (transformProps.has(key) ||
|
|
@@ -7,7 +7,9 @@ import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
|
7
7
|
*/
|
|
8
8
|
function useMotionRef(visualState, visualElement, externalRef) {
|
|
9
9
|
return useCallback((instance) => {
|
|
10
|
-
|
|
10
|
+
if (instance) {
|
|
11
|
+
visualState.onMount && visualState.onMount(instance);
|
|
12
|
+
}
|
|
11
13
|
if (visualElement) {
|
|
12
14
|
if (instance) {
|
|
13
15
|
visualElement.mount(instance);
|
|
@@ -15,7 +15,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
15
15
|
const lazyContext = useContext(LazyContext);
|
|
16
16
|
const presenceContext = useContext(PresenceContext);
|
|
17
17
|
const reducedMotionConfig = useContext(MotionConfigContext).reducedMotion;
|
|
18
|
-
const visualElementRef = useRef(
|
|
18
|
+
const visualElementRef = useRef(null);
|
|
19
19
|
/**
|
|
20
20
|
* If we haven't preloaded a renderer, check to see if we have one lazy-loaded
|
|
21
21
|
*/
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { isAnimationControls } from '../../animation/utils/is-animation-controls.mjs';
|
|
3
|
+
import { MotionContext } from '../../context/MotionContext/index.mjs';
|
|
3
4
|
import { PresenceContext } from '../../context/PresenceContext.mjs';
|
|
5
|
+
import { isControllingVariants, isVariantNode } from '../../render/utils/is-controlling-variants.mjs';
|
|
4
6
|
import { resolveVariantFromProps } from '../../render/utils/resolve-variants.mjs';
|
|
5
7
|
import { useConstant } from '../../utils/use-constant.mjs';
|
|
6
8
|
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
7
|
-
import { MotionContext } from '../../context/MotionContext/index.mjs';
|
|
8
|
-
import { isControllingVariants, isVariantNode } from '../../render/utils/is-controlling-variants.mjs';
|
|
9
9
|
|
|
10
|
-
function makeState({ scrapeMotionValuesFromProps, createRenderState,
|
|
10
|
+
function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
|
|
11
11
|
const state = {
|
|
12
12
|
latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
|
|
13
13
|
renderState: createRenderState(),
|
|
14
14
|
};
|
|
15
|
-
if (
|
|
16
|
-
|
|
15
|
+
if (onUpdate) {
|
|
16
|
+
/**
|
|
17
|
+
* onMount works without the VisualElement because it could be
|
|
18
|
+
* called before the VisualElement payload has been hydrated.
|
|
19
|
+
* (e.g. if someone is using m components <m.circle />)
|
|
20
|
+
*/
|
|
21
|
+
state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
|
|
22
|
+
state.onUpdate = (visualElement) => onUpdate(visualElement);
|
|
17
23
|
}
|
|
18
24
|
return state;
|
|
19
25
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { progress } from '../../../../../motion-utils/dist/es/progress.mjs';
|
|
1
4
|
import { circOut } from '../../easing/circ.mjs';
|
|
2
|
-
import { progress } from '../../utils/progress.mjs';
|
|
3
5
|
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
4
|
-
import { noop } from '../../utils/noop.mjs';
|
|
5
6
|
import { percent, px } from '../../value/types/numbers/units.mjs';
|
|
6
7
|
|
|
7
8
|
const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|