framer-motion 5.3.2 → 5.4.0-beta.2
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/dist/es/animation/utils/easing.mjs +1 -1
- package/dist/es/animation/utils/transitions.mjs +1 -1
- package/dist/es/components/AnimatePresence/index.mjs +1 -1
- package/dist/es/components/AnimatePresence/use-presence.mjs +1 -27
- package/dist/es/components/AnimateSharedLayout.mjs +1 -1
- package/dist/es/components/MotionCanvas/index.mjs +14 -0
- package/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/context/MotionContext/index.mjs +1 -1
- package/dist/es/events/use-dom-event.mjs +2 -31
- package/dist/es/events/use-pointer-event.mjs +2 -5
- package/dist/es/gestures/utils/event-type.mjs +1 -8
- package/dist/es/motion/index.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +1 -1
- package/dist/es/projection/geometry/models.mjs +1 -11
- package/dist/es/projection/node/create-projection-node.mjs +4 -1167
- package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
- package/dist/es/projection/styles/transform.mjs +5 -5
- package/dist/es/render/dom/motion-proxy.mjs +3 -0
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +2 -2
- package/dist/es/render/dom/utils/filter-props.mjs +3 -1
- package/dist/es/render/dom/value-types/dimensions.mjs +1 -8
- package/dist/es/render/html/use-props.mjs +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +2 -2
- package/dist/es/render/svg/utils/path.mjs +1 -1
- package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
- package/dist/es/render/three/create-visual-element.mjs +42 -0
- package/dist/es/render/three/gestures/use-hover.mjs +22 -0
- package/dist/es/render/three/gestures/use-tap.mjs +56 -0
- package/dist/es/render/three/motion.mjs +30 -0
- package/dist/es/render/three/use-render.mjs +11 -0
- package/dist/es/render/three/utils/read-value.mjs +43 -0
- package/dist/es/render/three/utils/set-value.mjs +59 -0
- package/dist/es/render/utils/animation.mjs +1 -4
- package/dist/es/render/utils/setters.mjs +2 -39
- package/dist/es/three-entry.mjs +2 -0
- package/dist/es/utils/array.mjs +2 -13
- package/dist/framer-motion-three.cjs.js +3004 -0
- package/dist/framer-motion.cjs.js +46 -43
- package/dist/framer-motion.dev.js +35 -32
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +17 -17
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/package.json +27 -6
- package/types/components/MotionCanvas/index.d.ts +4 -0
- package/types/motion/features/types.d.ts +1 -1
- package/types/render/three/create-visual-element.d.ts +6 -0
- package/types/render/three/gestures/use-hover.d.ts +10 -0
- package/types/render/three/gestures/use-tap.d.ts +8 -0
- package/types/render/three/motion.d.ts +5 -0
- package/types/render/three/types.d.ts +24 -0
- package/types/render/three/use-render.d.ts +4 -0
- package/types/render/three/utils/read-value.d.ts +2 -0
- package/types/render/three/utils/set-value.d.ts +2 -0
- package/types/render/utils/lifecycles.d.ts +8 -8
- package/types/render/utils/setters.d.ts +1 -0
- package/types/three-entry.d.ts +2 -0
|
@@ -27,7 +27,7 @@ var easingDefinitionToFunction = function (definition) {
|
|
|
27
27
|
}
|
|
28
28
|
else if (typeof definition === "string") {
|
|
29
29
|
// Else lookup from table
|
|
30
|
-
invariant(easingLookup[definition] !== undefined, "Invalid easing type '"
|
|
30
|
+
invariant(easingLookup[definition] !== undefined, "Invalid easing type '".concat(definition, "'"));
|
|
31
31
|
return easingLookup[definition];
|
|
32
32
|
}
|
|
33
33
|
return definition;
|
|
@@ -126,7 +126,7 @@ function getAnimation(key, value, target, transition, onComplete) {
|
|
|
126
126
|
target = getZeroUnit(origin);
|
|
127
127
|
}
|
|
128
128
|
var isOriginAnimatable = isAnimatable(key, origin);
|
|
129
|
-
warning(isOriginAnimatable === isTargetAnimatable, "You are trying to animate "
|
|
129
|
+
warning(isOriginAnimatable === isTargetAnimatable, "You are trying to animate ".concat(key, " from \"").concat(origin, "\" to \"").concat(target, "\". ").concat(origin, " is not an animatable value - to enable this animation set ").concat(origin, " to a value animatable to ").concat(target, " via the `style` property."));
|
|
130
130
|
function start() {
|
|
131
131
|
var options = {
|
|
132
132
|
from: origin,
|
|
@@ -14,7 +14,7 @@ function updateChildLookup(children, allChildren) {
|
|
|
14
14
|
var key = getChildKey(child);
|
|
15
15
|
if (process.env.NODE_ENV !== "production" && seenChildren) {
|
|
16
16
|
if (seenChildren.has(key)) {
|
|
17
|
-
console.warn("Children of AnimatePresence require unique keys. \""
|
|
17
|
+
console.warn("Children of AnimatePresence require unique keys. \"".concat(key, "\" is a duplicate."));
|
|
18
18
|
}
|
|
19
19
|
seenChildren.add(key);
|
|
20
20
|
}
|
|
@@ -38,34 +38,8 @@ function usePresence() {
|
|
|
38
38
|
var safeToRemove = function () { return onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete(id); };
|
|
39
39
|
return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.
|
|
43
|
-
* There is no `safeToRemove` function.
|
|
44
|
-
*
|
|
45
|
-
* ```jsx
|
|
46
|
-
* import { useIsPresent } from "framer-motion"
|
|
47
|
-
*
|
|
48
|
-
* export const Component = () => {
|
|
49
|
-
* const isPresent = useIsPresent()
|
|
50
|
-
*
|
|
51
|
-
* useEffect(() => {
|
|
52
|
-
* !isPresent && console.log("I've been removed!")
|
|
53
|
-
* }, [isPresent])
|
|
54
|
-
*
|
|
55
|
-
* return <div />
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
function useIsPresent() {
|
|
62
|
-
return isPresent(useContext(PresenceContext));
|
|
63
|
-
}
|
|
64
|
-
function isPresent(context) {
|
|
65
|
-
return context === null ? true : context.isPresent;
|
|
66
|
-
}
|
|
67
41
|
var counter = 0;
|
|
68
42
|
var incrementId = function () { return counter++; };
|
|
69
43
|
var useUniqueId = function () { return useConstant(incrementId); };
|
|
70
44
|
|
|
71
|
-
export {
|
|
45
|
+
export { usePresence };
|
|
@@ -5,7 +5,7 @@ import { LayoutGroup } from './LayoutGroup/index.mjs';
|
|
|
5
5
|
var id = 0;
|
|
6
6
|
var AnimateSharedLayout = function (_a) {
|
|
7
7
|
var children = _a.children;
|
|
8
|
-
return (React.createElement(LayoutGroup, { id: useConstant(function () { return "asl-"
|
|
8
|
+
return (React.createElement(LayoutGroup, { id: useConstant(function () { return "asl-".concat(id++); }) }, children));
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { AnimateSharedLayout };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { Canvas } from '@react-three/fiber';
|
|
5
|
+
import { MotionContext } from '../../context/MotionContext/index.mjs';
|
|
6
|
+
|
|
7
|
+
function MotionCanvas(_a) {
|
|
8
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
9
|
+
var motionContext = useContext(MotionContext);
|
|
10
|
+
return (React.createElement(Canvas, __assign({}, props),
|
|
11
|
+
React.createElement(MotionContext.Provider, { value: motionContext }, children)));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { MotionCanvas };
|
|
@@ -23,7 +23,7 @@ function ReorderItem(_a, externalRef) {
|
|
|
23
23
|
};
|
|
24
24
|
var zIndex = useTransform([point.x, point.y], function (_a) {
|
|
25
25
|
var _b = __read(_a, 2), latestX = _b[0], latestY = _b[1];
|
|
26
|
-
return latestX || latestY ? 1 :
|
|
26
|
+
return latestX || latestY ? 1 : "unset";
|
|
27
27
|
});
|
|
28
28
|
var layout = useRef(null);
|
|
29
29
|
invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
|
|
@@ -1,37 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'react';
|
|
2
2
|
|
|
3
3
|
function addDomEvent(target, eventName, handler, options) {
|
|
4
4
|
target.addEventListener(eventName, handler, options);
|
|
5
5
|
return function () { return target.removeEventListener(eventName, handler, options); };
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Attaches an event listener directly to the provided DOM element.
|
|
9
|
-
*
|
|
10
|
-
* Bypassing React's event system can be desirable, for instance when attaching non-passive
|
|
11
|
-
* event handlers.
|
|
12
|
-
*
|
|
13
|
-
* ```jsx
|
|
14
|
-
* const ref = useRef(null)
|
|
15
|
-
*
|
|
16
|
-
* useDomEvent(ref, 'wheel', onWheel, { passive: false })
|
|
17
|
-
*
|
|
18
|
-
* return <div ref={ref} />
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @param ref - React.RefObject that's been provided to the element you want to bind the listener to.
|
|
22
|
-
* @param eventName - Name of the event you want listen for.
|
|
23
|
-
* @param handler - Function to fire when receiving the event.
|
|
24
|
-
* @param options - Options to pass to `Event.addEventListener`.
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
function useDomEvent(ref, eventName, handler, options) {
|
|
29
|
-
useEffect(function () {
|
|
30
|
-
var element = ref.current;
|
|
31
|
-
if (handler && element) {
|
|
32
|
-
return addDomEvent(element, eventName, handler, options);
|
|
33
|
-
}
|
|
34
|
-
}, [ref, eventName, handler, options]);
|
|
35
|
-
}
|
|
36
7
|
|
|
37
|
-
export { addDomEvent
|
|
8
|
+
export { addDomEvent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addDomEvent } from './use-dom-event.mjs';
|
|
2
2
|
import { wrapHandler } from './event-info.mjs';
|
|
3
3
|
import { supportsPointerEvents, supportsTouchEvents, supportsMouseEvents } from './utils.mjs';
|
|
4
4
|
|
|
@@ -33,8 +33,5 @@ function getPointerEventName(name) {
|
|
|
33
33
|
function addPointerEvent(target, eventName, handler, options) {
|
|
34
34
|
return addDomEvent(target, getPointerEventName(eventName), wrapHandler(handler, eventName === "pointerdown"), options);
|
|
35
35
|
}
|
|
36
|
-
function usePointerEvent(ref, eventName, handler, options) {
|
|
37
|
-
return useDomEvent(ref, getPointerEventName(eventName), handler && wrapHandler(handler, eventName === "pointerdown"), options);
|
|
38
|
-
}
|
|
39
36
|
|
|
40
|
-
export { addPointerEvent
|
|
37
|
+
export { addPointerEvent };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
function isMouseEvent(event) {
|
|
2
|
-
// PointerEvent inherits from MouseEvent so we can't use a straight instanceof check.
|
|
3
|
-
if (typeof PointerEvent !== "undefined" && event instanceof PointerEvent) {
|
|
4
|
-
return !!(event.pointerType === "mouse");
|
|
5
|
-
}
|
|
6
|
-
return event instanceof MouseEvent;
|
|
7
|
-
}
|
|
8
1
|
function isTouchEvent(event) {
|
|
9
2
|
var hasTouches = !!event.touches;
|
|
10
3
|
return hasTouches;
|
|
11
4
|
}
|
|
12
5
|
|
|
13
|
-
export {
|
|
6
|
+
export { isTouchEvent };
|
package/dist/es/motion/index.mjs
CHANGED
|
@@ -78,7 +78,7 @@ function createMotionComponent(_a) {
|
|
|
78
78
|
*/
|
|
79
79
|
return (React.createElement(VisualElementHandler, { visualElement: context.visualElement, props: __assign(__assign({}, config), props) },
|
|
80
80
|
features,
|
|
81
|
-
React.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, config.isStatic))));
|
|
81
|
+
React.createElement(MotionContext.Provider, { value: context }, useRender(Component, props, projectionId, useMotionRef(visualState, context.visualElement, externalRef), visualState, config.isStatic, context.visualElement))));
|
|
82
82
|
}
|
|
83
83
|
return forwardRef(MotionComponent);
|
|
84
84
|
}
|
|
@@ -18,7 +18,7 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
|
|
|
18
18
|
* Mix border radius
|
|
19
19
|
*/
|
|
20
20
|
for (var i = 0; i < numBorders; i++) {
|
|
21
|
-
var borderLabel = "border"
|
|
21
|
+
var borderLabel = "border".concat(borders[i], "Radius");
|
|
22
22
|
var followRadius = getRadius(follow, borderLabel);
|
|
23
23
|
var leadRadius = getRadius(lead, borderLabel);
|
|
24
24
|
if (followRadius === undefined && leadRadius === undefined)
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
var createAxisDelta = function () { return ({
|
|
2
|
-
translate: 0,
|
|
3
|
-
scale: 1,
|
|
4
|
-
origin: 0,
|
|
5
|
-
originPoint: 0,
|
|
6
|
-
}); };
|
|
7
|
-
var createDelta = function () { return ({
|
|
8
|
-
x: createAxisDelta(),
|
|
9
|
-
y: createAxisDelta(),
|
|
10
|
-
}); };
|
|
11
1
|
var createAxis = function () { return ({ min: 0, max: 0 }); };
|
|
12
2
|
var createBox = function () { return ({
|
|
13
3
|
x: createAxis(),
|
|
14
4
|
y: createAxis(),
|
|
15
5
|
}); };
|
|
16
6
|
|
|
17
|
-
export { createAxis,
|
|
7
|
+
export { createAxis, createBox };
|