motion 11.11.12 → 11.11.14
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/.turbo/turbo-build.log +12 -9
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/react-client.js +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +5 -1
- package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +80 -0
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animate-style.mjs +17 -0
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animate.mjs +17 -0
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animated-state.mjs +64 -0
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animation.mjs +41 -0
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +8 -0
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +40 -0
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +173 -0
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +8 -0
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store.mjs +4 -0
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs +77 -0
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs +61 -0
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +163 -0
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +27 -1
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/utils.mjs +14 -0
- package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +15 -0
- package/dist/es/framer-motion/dist/es/components/LayoutGroup/index.mjs +32 -0
- package/dist/es/framer-motion/dist/es/components/LazyMotion/index.mjs +68 -0
- package/dist/es/framer-motion/dist/es/components/MotionConfig/index.mjs +48 -0
- package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +53 -0
- package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +34 -0
- package/dist/es/framer-motion/dist/es/components/Reorder/namespace.mjs +2 -0
- package/dist/es/framer-motion/dist/es/components/Reorder/utils/check-reorder.mjs +24 -0
- package/dist/es/framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs +10 -0
- package/dist/es/framer-motion/dist/es/context/ReorderContext.mjs +6 -0
- package/dist/es/framer-motion/dist/es/events/use-dom-event.mjs +34 -0
- package/dist/es/framer-motion/dist/es/frameloop/batcher.mjs +4 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/use-drag-controls.mjs +88 -0
- package/dist/es/framer-motion/dist/es/motion/utils/is-motion-component.mjs +12 -0
- package/dist/es/framer-motion/dist/es/motion/utils/unwrap-motion-component.mjs +17 -0
- package/dist/es/framer-motion/dist/es/projection/node/group.mjs +24 -0
- package/dist/es/framer-motion/dist/es/projection/use-instant-layout-transition.mjs +14 -0
- package/dist/es/framer-motion/dist/es/projection/use-reset-projection.mjs +14 -0
- package/dist/es/framer-motion/dist/es/render/components/create-proxy.mjs +38 -0
- package/dist/es/framer-motion/dist/es/render/components/m/proxy.mjs +6 -0
- package/dist/es/framer-motion/dist/es/render/components/motion/proxy.mjs +6 -0
- package/dist/es/framer-motion/dist/es/render/dom/features-animation.mjs +14 -0
- package/dist/es/framer-motion/dist/es/render/dom/features-max.mjs +14 -0
- package/dist/es/framer-motion/dist/es/render/dom/features-min.mjs +12 -0
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/array.mjs +11 -1
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs +19 -0
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs +47 -0
- package/dist/es/framer-motion/dist/es/utils/use-animation-frame.mjs +21 -0
- package/dist/es/framer-motion/dist/es/utils/use-cycle.mjs +47 -0
- package/dist/es/framer-motion/dist/es/utils/use-force-update.mjs +19 -0
- package/dist/es/framer-motion/dist/es/utils/use-in-view.mjs +23 -0
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition-state.mjs +5 -0
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +41 -0
- package/dist/es/framer-motion/dist/es/utils/use-is-mounted.mjs +15 -0
- package/dist/es/framer-motion/dist/es/utils/use-motion-value-event.mjs +13 -0
- package/dist/es/framer-motion/dist/es/utils/use-unmount-effect.mjs +7 -0
- package/dist/es/framer-motion/dist/es/value/index.mjs +8 -2
- package/dist/es/framer-motion/dist/es/value/scroll/use-element-scroll.mjs +14 -0
- package/dist/es/framer-motion/dist/es/value/scroll/use-viewport-scroll.mjs +14 -0
- package/dist/es/framer-motion/dist/es/value/types/color/rgba.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-combine-values.mjs +37 -0
- package/dist/es/framer-motion/dist/es/value/use-computed.mjs +19 -0
- package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +52 -0
- package/dist/es/framer-motion/dist/es/value/use-motion-template.mjs +45 -0
- package/dist/es/framer-motion/dist/es/value/use-motion-value.mjs +38 -0
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +39 -0
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +85 -0
- package/dist/es/framer-motion/dist/es/value/use-time.mjs +10 -0
- package/dist/es/framer-motion/dist/es/value/use-transform.mjs +29 -0
- package/dist/es/framer-motion/dist/es/value/use-velocity.mjs +35 -0
- package/dist/es/framer-motion/dist/es/value/use-will-change/WillChangeMotionValue.mjs +22 -0
- package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +14 -0
- package/dist/es/framer-motion/dist/es/value/use-will-change/index.mjs +8 -0
- package/dist/es/motion/lib/react.mjs +110 -0
- package/dist/motion.dev.js +2 -2
- package/dist/motion.js +1 -1
- package/dist/react.d.ts +1 -0
- package/package.json +17 -17
- package/react/package.json +1 -1
- package/react-client/package.json +1 -1
- package/react-m/package.json +1 -1
- package/rollup.config.mjs +12 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useMotionValue } from './use-motion-value.mjs';
|
|
2
|
+
import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
|
|
3
|
+
import { cancelFrame, frame } from '../frameloop/frame.mjs';
|
|
4
|
+
|
|
5
|
+
function useCombineMotionValues(values, combineValues) {
|
|
6
|
+
/**
|
|
7
|
+
* Initialise the returned motion value. This remains the same between renders.
|
|
8
|
+
*/
|
|
9
|
+
const value = useMotionValue(combineValues());
|
|
10
|
+
/**
|
|
11
|
+
* Create a function that will update the template motion value with the latest values.
|
|
12
|
+
* This is pre-bound so whenever a motion value updates it can schedule its
|
|
13
|
+
* execution in Framesync. If it's already been scheduled it won't be fired twice
|
|
14
|
+
* in a single frame.
|
|
15
|
+
*/
|
|
16
|
+
const updateValue = () => value.set(combineValues());
|
|
17
|
+
/**
|
|
18
|
+
* Synchronously update the motion value with the latest values during the render.
|
|
19
|
+
* This ensures that within a React render, the styles applied to the DOM are up-to-date.
|
|
20
|
+
*/
|
|
21
|
+
updateValue();
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to all motion values found within the template. Whenever any of them change,
|
|
24
|
+
* schedule an update.
|
|
25
|
+
*/
|
|
26
|
+
useIsomorphicLayoutEffect(() => {
|
|
27
|
+
const scheduleUpdate = () => frame.preRender(updateValue, false, true);
|
|
28
|
+
const subscriptions = values.map((v) => v.on("change", scheduleUpdate));
|
|
29
|
+
return () => {
|
|
30
|
+
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
31
|
+
cancelFrame(updateValue);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { useCombineMotionValues };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { collectMotionValues } from './index.mjs';
|
|
2
|
+
import { useCombineMotionValues } from './use-combine-values.mjs';
|
|
3
|
+
|
|
4
|
+
function useComputed(compute) {
|
|
5
|
+
/**
|
|
6
|
+
* Open session of collectMotionValues. Any MotionValue that calls get()
|
|
7
|
+
* will be saved into this array.
|
|
8
|
+
*/
|
|
9
|
+
collectMotionValues.current = [];
|
|
10
|
+
compute();
|
|
11
|
+
const value = useCombineMotionValues(collectMotionValues.current, compute);
|
|
12
|
+
/**
|
|
13
|
+
* Synchronously close session of collectMotionValues.
|
|
14
|
+
*/
|
|
15
|
+
collectMotionValues.current = undefined;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { useComputed };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useTransform } from './use-transform.mjs';
|
|
2
|
+
import { invariant, warning } from '../utils/errors.mjs';
|
|
3
|
+
import { useMotionValue } from './use-motion-value.mjs';
|
|
4
|
+
import { MotionContext } from '../context/MotionContext/index.mjs';
|
|
5
|
+
import { useContext } from 'react';
|
|
6
|
+
|
|
7
|
+
// Keep things reasonable and avoid scale: Infinity. In practise we might need
|
|
8
|
+
// to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]
|
|
9
|
+
// to simply hide content at unreasonable scales.
|
|
10
|
+
const maxScale = 100000;
|
|
11
|
+
const invertScale = (scale) => scale > 0.001 ? 1 / scale : maxScale;
|
|
12
|
+
let hasWarned = false;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
|
|
15
|
+
* of their respective parent scales.
|
|
16
|
+
*
|
|
17
|
+
* This is useful for undoing the distortion of content when scaling a parent component.
|
|
18
|
+
*
|
|
19
|
+
* By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
|
|
20
|
+
* By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
|
|
21
|
+
* of those instead.
|
|
22
|
+
*
|
|
23
|
+
* ```jsx
|
|
24
|
+
* const MyComponent = () => {
|
|
25
|
+
* const { scaleX, scaleY } = useInvertedScale()
|
|
26
|
+
* return <motion.div style={{ scaleX, scaleY }} />
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @deprecated
|
|
31
|
+
*/
|
|
32
|
+
function useInvertedScale(scale) {
|
|
33
|
+
let parentScaleX = useMotionValue(1);
|
|
34
|
+
let parentScaleY = useMotionValue(1);
|
|
35
|
+
const { visualElement } = useContext(MotionContext);
|
|
36
|
+
invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
37
|
+
warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
38
|
+
hasWarned = true;
|
|
39
|
+
if (scale) {
|
|
40
|
+
parentScaleX = scale.scaleX || parentScaleX;
|
|
41
|
+
parentScaleY = scale.scaleY || parentScaleY;
|
|
42
|
+
}
|
|
43
|
+
else if (visualElement) {
|
|
44
|
+
parentScaleX = visualElement.getValue("scaleX", 1);
|
|
45
|
+
parentScaleY = visualElement.getValue("scaleY", 1);
|
|
46
|
+
}
|
|
47
|
+
const scaleX = useTransform(parentScaleX, invertScale);
|
|
48
|
+
const scaleY = useTransform(parentScaleY, invertScale);
|
|
49
|
+
return { scaleX, scaleY };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { invertScale, useInvertedScale };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCombineMotionValues } from './use-combine-values.mjs';
|
|
2
|
+
import { isMotionValue } from './utils/is-motion-value.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Combine multiple motion values into a new one using a string template literal.
|
|
6
|
+
*
|
|
7
|
+
* ```jsx
|
|
8
|
+
* import {
|
|
9
|
+
* motion,
|
|
10
|
+
* useSpring,
|
|
11
|
+
* useMotionValue,
|
|
12
|
+
* useMotionTemplate
|
|
13
|
+
* } from "framer-motion"
|
|
14
|
+
*
|
|
15
|
+
* function Component() {
|
|
16
|
+
* const shadowX = useSpring(0)
|
|
17
|
+
* const shadowY = useMotionValue(0)
|
|
18
|
+
* const shadow = useMotionTemplate`drop-shadow(${shadowX}px ${shadowY}px 20px rgba(0,0,0,0.3))`
|
|
19
|
+
*
|
|
20
|
+
* return <motion.div style={{ filter: shadow }} />
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
function useMotionTemplate(fragments, ...values) {
|
|
27
|
+
/**
|
|
28
|
+
* Create a function that will build a string from the latest motion values.
|
|
29
|
+
*/
|
|
30
|
+
const numFragments = fragments.length;
|
|
31
|
+
function buildValue() {
|
|
32
|
+
let output = ``;
|
|
33
|
+
for (let i = 0; i < numFragments; i++) {
|
|
34
|
+
output += fragments[i];
|
|
35
|
+
const value = values[i];
|
|
36
|
+
if (value) {
|
|
37
|
+
output += isMotionValue(value) ? value.get() : value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return output;
|
|
41
|
+
}
|
|
42
|
+
return useCombineMotionValues(values.filter(isMotionValue), buildValue);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { useMotionTemplate };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useContext, useState, useEffect } from 'react';
|
|
2
|
+
import { motionValue } from './index.mjs';
|
|
3
|
+
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
4
|
+
import { useConstant } from '../utils/use-constant.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a `MotionValue` to track the state and velocity of a value.
|
|
8
|
+
*
|
|
9
|
+
* Usually, these are created automatically. For advanced use-cases, like use with `useTransform`, you can create `MotionValue`s externally and pass them into the animated component via the `style` prop.
|
|
10
|
+
*
|
|
11
|
+
* ```jsx
|
|
12
|
+
* export const MyComponent = () => {
|
|
13
|
+
* const scale = useMotionValue(1)
|
|
14
|
+
*
|
|
15
|
+
* return <motion.div style={{ scale }} />
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param initial - The initial state.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
function useMotionValue(initial) {
|
|
24
|
+
const value = useConstant(() => motionValue(initial));
|
|
25
|
+
/**
|
|
26
|
+
* If this motion value is being used in static mode, like on
|
|
27
|
+
* the Framer canvas, force components to rerender when the motion
|
|
28
|
+
* value is updated.
|
|
29
|
+
*/
|
|
30
|
+
const { isStatic } = useContext(MotionConfigContext);
|
|
31
|
+
if (isStatic) {
|
|
32
|
+
const [, setLatest] = useState(initial);
|
|
33
|
+
useEffect(() => value.on("change", setLatest), []);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { useMotionValue };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { motionValue } from './index.mjs';
|
|
2
|
+
import { useConstant } from '../utils/use-constant.mjs';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { warning } from '../utils/errors.mjs';
|
|
5
|
+
import { scroll } from '../render/dom/scroll/index.mjs';
|
|
6
|
+
import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
|
|
7
|
+
|
|
8
|
+
function refWarning(name, ref) {
|
|
9
|
+
warning(Boolean(!ref || ref.current), `You have defined a ${name} options but the provided ref is not yet hydrated, probably because it's defined higher up the tree. Try calling useScroll() in the same component as the ref, or setting its \`layoutEffect: false\` option.`);
|
|
10
|
+
}
|
|
11
|
+
const createScrollMotionValues = () => ({
|
|
12
|
+
scrollX: motionValue(0),
|
|
13
|
+
scrollY: motionValue(0),
|
|
14
|
+
scrollXProgress: motionValue(0),
|
|
15
|
+
scrollYProgress: motionValue(0),
|
|
16
|
+
});
|
|
17
|
+
function useScroll({ container, target, layoutEffect = true, ...options } = {}) {
|
|
18
|
+
const values = useConstant(createScrollMotionValues);
|
|
19
|
+
const useLifecycleEffect = layoutEffect
|
|
20
|
+
? useIsomorphicLayoutEffect
|
|
21
|
+
: useEffect;
|
|
22
|
+
useLifecycleEffect(() => {
|
|
23
|
+
refWarning("target", target);
|
|
24
|
+
refWarning("container", container);
|
|
25
|
+
return scroll((_progress, { x, y }) => {
|
|
26
|
+
values.scrollX.set(x.current);
|
|
27
|
+
values.scrollXProgress.set(x.progress);
|
|
28
|
+
values.scrollY.set(y.current);
|
|
29
|
+
values.scrollYProgress.set(y.progress);
|
|
30
|
+
}, {
|
|
31
|
+
...options,
|
|
32
|
+
container: (container === null || container === void 0 ? void 0 : container.current) || undefined,
|
|
33
|
+
target: (target === null || target === void 0 ? void 0 : target.current) || undefined,
|
|
34
|
+
});
|
|
35
|
+
}, [container, target, JSON.stringify(options.offset)]);
|
|
36
|
+
return values;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { useScroll };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useContext, useRef, useInsertionEffect } from 'react';
|
|
2
|
+
import { isMotionValue } from './utils/is-motion-value.mjs';
|
|
3
|
+
import { useMotionValue } from './use-motion-value.mjs';
|
|
4
|
+
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
5
|
+
import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
|
|
6
|
+
import { animateValue } from '../animation/animators/MainThreadAnimation.mjs';
|
|
7
|
+
import { frame, frameData } from '../frameloop/frame.mjs';
|
|
8
|
+
|
|
9
|
+
function toNumber(v) {
|
|
10
|
+
if (typeof v === "number")
|
|
11
|
+
return v;
|
|
12
|
+
return parseFloat(v);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.
|
|
16
|
+
*
|
|
17
|
+
* It can either work as a stand-alone `MotionValue` by initialising it with a value, or as a subscriber
|
|
18
|
+
* to another `MotionValue`.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
*
|
|
22
|
+
* ```jsx
|
|
23
|
+
* const x = useSpring(0, { stiffness: 300 })
|
|
24
|
+
* const y = useSpring(x, { damping: 10 })
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param inputValue - `MotionValue` or number. If provided a `MotionValue`, when the input `MotionValue` changes, the created `MotionValue` will spring towards that value.
|
|
28
|
+
* @param springConfig - Configuration options for the spring.
|
|
29
|
+
* @returns `MotionValue`
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
function useSpring(source, config = {}) {
|
|
34
|
+
const { isStatic } = useContext(MotionConfigContext);
|
|
35
|
+
const activeSpringAnimation = useRef(null);
|
|
36
|
+
const value = useMotionValue(isMotionValue(source) ? toNumber(source.get()) : source);
|
|
37
|
+
const latestValue = useRef(value.get());
|
|
38
|
+
const latestSetter = useRef(() => { });
|
|
39
|
+
const startAnimation = () => {
|
|
40
|
+
/**
|
|
41
|
+
* If the previous animation hasn't had the chance to even render a frame, render it now.
|
|
42
|
+
*/
|
|
43
|
+
const animation = activeSpringAnimation.current;
|
|
44
|
+
if (animation && animation.time === 0) {
|
|
45
|
+
animation.sample(frameData.delta);
|
|
46
|
+
}
|
|
47
|
+
stopAnimation();
|
|
48
|
+
activeSpringAnimation.current = animateValue({
|
|
49
|
+
keyframes: [value.get(), latestValue.current],
|
|
50
|
+
velocity: value.getVelocity(),
|
|
51
|
+
type: "spring",
|
|
52
|
+
restDelta: 0.001,
|
|
53
|
+
restSpeed: 0.01,
|
|
54
|
+
...config,
|
|
55
|
+
onUpdate: latestSetter.current,
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const stopAnimation = () => {
|
|
59
|
+
if (activeSpringAnimation.current) {
|
|
60
|
+
activeSpringAnimation.current.stop();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
useInsertionEffect(() => {
|
|
64
|
+
return value.attach((v, set) => {
|
|
65
|
+
/**
|
|
66
|
+
* A more hollistic approach to this might be to use isStatic to fix VisualElement animations
|
|
67
|
+
* at that level, but this will work for now
|
|
68
|
+
*/
|
|
69
|
+
if (isStatic)
|
|
70
|
+
return set(v);
|
|
71
|
+
latestValue.current = v;
|
|
72
|
+
latestSetter.current = set;
|
|
73
|
+
frame.update(startAnimation);
|
|
74
|
+
return value.get();
|
|
75
|
+
}, stopAnimation);
|
|
76
|
+
}, [JSON.stringify(config)]);
|
|
77
|
+
useIsomorphicLayoutEffect(() => {
|
|
78
|
+
if (isMotionValue(source)) {
|
|
79
|
+
return source.on("change", (v) => value.set(toNumber(v)));
|
|
80
|
+
}
|
|
81
|
+
}, [value]);
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { useSpring };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useAnimationFrame } from '../utils/use-animation-frame.mjs';
|
|
2
|
+
import { useMotionValue } from './use-motion-value.mjs';
|
|
3
|
+
|
|
4
|
+
function useTime() {
|
|
5
|
+
const time = useMotionValue(0);
|
|
6
|
+
useAnimationFrame((t) => time.set(t));
|
|
7
|
+
return time;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { useTime };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { transform } from '../utils/transform.mjs';
|
|
2
|
+
import { useCombineMotionValues } from './use-combine-values.mjs';
|
|
3
|
+
import { useConstant } from '../utils/use-constant.mjs';
|
|
4
|
+
import { useComputed } from './use-computed.mjs';
|
|
5
|
+
|
|
6
|
+
function useTransform(input, inputRangeOrTransformer, outputRange, options) {
|
|
7
|
+
if (typeof input === "function") {
|
|
8
|
+
return useComputed(input);
|
|
9
|
+
}
|
|
10
|
+
const transformer = typeof inputRangeOrTransformer === "function"
|
|
11
|
+
? inputRangeOrTransformer
|
|
12
|
+
: transform(inputRangeOrTransformer, outputRange, options);
|
|
13
|
+
return Array.isArray(input)
|
|
14
|
+
? useListTransform(input, transformer)
|
|
15
|
+
: useListTransform([input], ([latest]) => transformer(latest));
|
|
16
|
+
}
|
|
17
|
+
function useListTransform(values, transformer) {
|
|
18
|
+
const latest = useConstant(() => []);
|
|
19
|
+
return useCombineMotionValues(values, () => {
|
|
20
|
+
latest.length = 0;
|
|
21
|
+
const numValues = values.length;
|
|
22
|
+
for (let i = 0; i < numValues; i++) {
|
|
23
|
+
latest[i] = values[i].get();
|
|
24
|
+
}
|
|
25
|
+
return transformer(latest);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { useTransform };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMotionValueEvent } from '../utils/use-motion-value-event.mjs';
|
|
2
|
+
import { useMotionValue } from './use-motion-value.mjs';
|
|
3
|
+
import { frame } from '../frameloop/frame.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a `MotionValue` that updates when the velocity of the provided `MotionValue` changes.
|
|
7
|
+
*
|
|
8
|
+
* ```javascript
|
|
9
|
+
* const x = useMotionValue(0)
|
|
10
|
+
* const xVelocity = useVelocity(x)
|
|
11
|
+
* const xAcceleration = useVelocity(xVelocity)
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
function useVelocity(value) {
|
|
17
|
+
const velocity = useMotionValue(value.getVelocity());
|
|
18
|
+
const updateVelocity = () => {
|
|
19
|
+
const latest = value.getVelocity();
|
|
20
|
+
velocity.set(latest);
|
|
21
|
+
/**
|
|
22
|
+
* If we still have velocity, schedule an update for the next frame
|
|
23
|
+
* to keep checking until it is zero.
|
|
24
|
+
*/
|
|
25
|
+
if (latest)
|
|
26
|
+
frame.update(updateVelocity);
|
|
27
|
+
};
|
|
28
|
+
useMotionValueEvent(value, "change", () => {
|
|
29
|
+
// Schedule an update to this value at the end of the current frame.
|
|
30
|
+
frame.update(updateVelocity, false, true);
|
|
31
|
+
});
|
|
32
|
+
return velocity;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { useVelocity };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MotionValue } from '../index.mjs';
|
|
2
|
+
import { getWillChangeName } from './get-will-change-name.mjs';
|
|
3
|
+
import { addUniqueItem } from '../../utils/array.mjs';
|
|
4
|
+
|
|
5
|
+
class WillChangeMotionValue extends MotionValue {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.values = [];
|
|
9
|
+
}
|
|
10
|
+
add(name) {
|
|
11
|
+
const styleName = getWillChangeName(name);
|
|
12
|
+
if (styleName) {
|
|
13
|
+
addUniqueItem(this.values, styleName);
|
|
14
|
+
this.update();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
update() {
|
|
18
|
+
this.set(this.values.length ? this.values.join(", ") : "auto");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { WillChangeMotionValue };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { acceleratedValues } from '../../animation/animators/utils/accelerated-values.mjs';
|
|
2
|
+
import { camelToDash } from '../../render/dom/utils/camel-to-dash.mjs';
|
|
3
|
+
import { transformProps } from '../../render/html/utils/transform.mjs';
|
|
4
|
+
|
|
5
|
+
function getWillChangeName(name) {
|
|
6
|
+
if (transformProps.has(name)) {
|
|
7
|
+
return "transform";
|
|
8
|
+
}
|
|
9
|
+
else if (acceleratedValues.has(name)) {
|
|
10
|
+
return camelToDash(name);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { getWillChangeName };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { motion } from '../../framer-motion/dist/es/render/components/motion/proxy.mjs';
|
|
3
|
+
export { m } from '../../framer-motion/dist/es/render/components/m/proxy.mjs';
|
|
4
|
+
export { AnimatePresence } from '../../framer-motion/dist/es/components/AnimatePresence/index.mjs';
|
|
5
|
+
export { MotionConfig } from '../../framer-motion/dist/es/components/MotionConfig/index.mjs';
|
|
6
|
+
export { LazyMotion } from '../../framer-motion/dist/es/components/LazyMotion/index.mjs';
|
|
7
|
+
export { LayoutGroup } from '../../framer-motion/dist/es/components/LayoutGroup/index.mjs';
|
|
8
|
+
export { domMin } from '../../framer-motion/dist/es/render/dom/features-min.mjs';
|
|
9
|
+
export { domAnimation } from '../../framer-motion/dist/es/render/dom/features-animation.mjs';
|
|
10
|
+
export { domMax } from '../../framer-motion/dist/es/render/dom/features-max.mjs';
|
|
11
|
+
export { useMotionValue } from '../../framer-motion/dist/es/value/use-motion-value.mjs';
|
|
12
|
+
export { useMotionTemplate } from '../../framer-motion/dist/es/value/use-motion-template.mjs';
|
|
13
|
+
export { resolveMotionValue } from '../../framer-motion/dist/es/value/utils/resolve-motion-value.mjs';
|
|
14
|
+
export { useTransform } from '../../framer-motion/dist/es/value/use-transform.mjs';
|
|
15
|
+
export { useSpring } from '../../framer-motion/dist/es/value/use-spring.mjs';
|
|
16
|
+
export { useVelocity } from '../../framer-motion/dist/es/value/use-velocity.mjs';
|
|
17
|
+
export { useScroll } from '../../framer-motion/dist/es/value/use-scroll.mjs';
|
|
18
|
+
export { useElementScroll } from '../../framer-motion/dist/es/value/scroll/use-element-scroll.mjs';
|
|
19
|
+
export { useViewportScroll } from '../../framer-motion/dist/es/value/scroll/use-viewport-scroll.mjs';
|
|
20
|
+
export { useTime } from '../../framer-motion/dist/es/value/use-time.mjs';
|
|
21
|
+
export { useWillChange } from '../../framer-motion/dist/es/value/use-will-change/index.mjs';
|
|
22
|
+
export { useMotionValueEvent } from '../../framer-motion/dist/es/utils/use-motion-value-event.mjs';
|
|
23
|
+
export { useReducedMotion } from '../../framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs';
|
|
24
|
+
export { useReducedMotionConfig } from '../../framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs';
|
|
25
|
+
export { animationControls } from '../../framer-motion/dist/es/animation/hooks/animation-controls.mjs';
|
|
26
|
+
export { useAnimate } from '../../framer-motion/dist/es/animation/hooks/use-animate.mjs';
|
|
27
|
+
export { useAnimateMini } from '../../framer-motion/dist/es/animation/hooks/use-animate-style.mjs';
|
|
28
|
+
export { useAnimation, useAnimationControls } from '../../framer-motion/dist/es/animation/hooks/use-animation.mjs';
|
|
29
|
+
export { useAnimationFrame } from '../../framer-motion/dist/es/utils/use-animation-frame.mjs';
|
|
30
|
+
export { animateVisualElement } from '../../framer-motion/dist/es/animation/interfaces/visual-element.mjs';
|
|
31
|
+
export { useCycle } from '../../framer-motion/dist/es/utils/use-cycle.mjs';
|
|
32
|
+
export { isValidMotionProp } from '../../framer-motion/dist/es/motion/utils/valid-prop.mjs';
|
|
33
|
+
export { useIsPresent, usePresence } from '../../framer-motion/dist/es/components/AnimatePresence/use-presence.mjs';
|
|
34
|
+
export { useInView } from '../../framer-motion/dist/es/utils/use-in-view.mjs';
|
|
35
|
+
export { DragControls, useDragControls } from '../../framer-motion/dist/es/gestures/drag/use-drag-controls.mjs';
|
|
36
|
+
export { useDomEvent } from '../../framer-motion/dist/es/events/use-dom-event.mjs';
|
|
37
|
+
export { createRendererMotionComponent } from '../../framer-motion/dist/es/motion/index.mjs';
|
|
38
|
+
export { isMotionComponent } from '../../framer-motion/dist/es/motion/utils/is-motion-component.mjs';
|
|
39
|
+
export { unwrapMotionComponent } from '../../framer-motion/dist/es/motion/utils/unwrap-motion-component.mjs';
|
|
40
|
+
export { VisualElement } from '../../framer-motion/dist/es/render/VisualElement.mjs';
|
|
41
|
+
export { addScaleCorrector } from '../../framer-motion/dist/es/projection/styles/scale-correction.mjs';
|
|
42
|
+
export { disableInstantTransitions, useInstantTransition } from '../../framer-motion/dist/es/utils/use-instant-transition.mjs';
|
|
43
|
+
export { useInstantLayoutTransition } from '../../framer-motion/dist/es/projection/use-instant-layout-transition.mjs';
|
|
44
|
+
export { useResetProjection } from '../../framer-motion/dist/es/projection/use-reset-projection.mjs';
|
|
45
|
+
export { buildTransform } from '../../framer-motion/dist/es/render/html/utils/build-transform.mjs';
|
|
46
|
+
export { visualElementStore } from '../../framer-motion/dist/es/render/store.mjs';
|
|
47
|
+
export { animateValue } from '../../framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs';
|
|
48
|
+
export { color } from '../../framer-motion/dist/es/value/types/color/index.mjs';
|
|
49
|
+
export { complex } from '../../framer-motion/dist/es/value/types/complex/index.mjs';
|
|
50
|
+
export { px } from '../../framer-motion/dist/es/value/types/numbers/units.mjs';
|
|
51
|
+
export { MotionGlobalConfig } from '../../framer-motion/dist/es/utils/GlobalConfig.mjs';
|
|
52
|
+
export { AcceleratedAnimation } from '../../framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs';
|
|
53
|
+
export { startOptimizedAppearAnimation } from '../../framer-motion/dist/es/animation/optimized-appear/start.mjs';
|
|
54
|
+
export { optimizedAppearDataAttribute } from '../../framer-motion/dist/es/animation/optimized-appear/data-id.mjs';
|
|
55
|
+
export { spring } from '../../framer-motion/dist/es/animation/generators/spring/index.mjs';
|
|
56
|
+
export { findSpring } from '../../framer-motion/dist/es/animation/generators/spring/find.mjs';
|
|
57
|
+
export { MotionContext } from '../../framer-motion/dist/es/context/MotionContext/index.mjs';
|
|
58
|
+
export { MotionConfigContext } from '../../framer-motion/dist/es/context/MotionConfigContext.mjs';
|
|
59
|
+
export { PresenceContext } from '../../framer-motion/dist/es/context/PresenceContext.mjs';
|
|
60
|
+
export { LayoutGroupContext } from '../../framer-motion/dist/es/context/LayoutGroupContext.mjs';
|
|
61
|
+
export { SwitchLayoutGroupContext } from '../../framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs';
|
|
62
|
+
export { FlatTree } from '../../framer-motion/dist/es/render/utils/flat-tree.mjs';
|
|
63
|
+
export { DeprecatedLayoutGroupContext } from '../../framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs';
|
|
64
|
+
export { useAnimatedState as useDeprecatedAnimatedState } from '../../framer-motion/dist/es/animation/hooks/use-animated-state.mjs';
|
|
65
|
+
export { useInvertedScale as useDeprecatedInvertedScale } from '../../framer-motion/dist/es/value/use-inverted-scale.mjs';
|
|
66
|
+
export { AnimateSharedLayout } from '../../framer-motion/dist/es/components/AnimateSharedLayout.mjs';
|
|
67
|
+
export { delay } from '../../framer-motion/dist/es/utils/delay.mjs';
|
|
68
|
+
export { MotionValue, motionValue } from '../../framer-motion/dist/es/value/index.mjs';
|
|
69
|
+
export { animate, createScopedAnimate } from '../../framer-motion/dist/es/animation/animate/index.mjs';
|
|
70
|
+
export { animateMini } from '../../framer-motion/dist/es/animation/animators/waapi/animate-style.mjs';
|
|
71
|
+
export { scroll } from '../../framer-motion/dist/es/render/dom/scroll/index.mjs';
|
|
72
|
+
export { scrollInfo } from '../../framer-motion/dist/es/render/dom/scroll/track.mjs';
|
|
73
|
+
export { inView } from '../../framer-motion/dist/es/render/dom/viewport/index.mjs';
|
|
74
|
+
export { inertia } from '../../framer-motion/dist/es/animation/generators/inertia.mjs';
|
|
75
|
+
export { keyframes } from '../../framer-motion/dist/es/animation/generators/keyframes.mjs';
|
|
76
|
+
export { stagger } from '../../framer-motion/dist/es/animation/utils/stagger.mjs';
|
|
77
|
+
export { transform } from '../../framer-motion/dist/es/utils/transform.mjs';
|
|
78
|
+
export { clamp } from '../../framer-motion/dist/es/utils/clamp.mjs';
|
|
79
|
+
export { mix } from '../../framer-motion/dist/es/utils/mix/index.mjs';
|
|
80
|
+
export { pipe } from '../../framer-motion/dist/es/utils/pipe.mjs';
|
|
81
|
+
export { progress } from '../../framer-motion/dist/es/utils/progress.mjs';
|
|
82
|
+
export { wrap } from '../../framer-motion/dist/es/utils/wrap.mjs';
|
|
83
|
+
export { cancelSync, sync } from '../../framer-motion/dist/es/frameloop/index-legacy.mjs';
|
|
84
|
+
export { anticipate } from '../../framer-motion/dist/es/easing/anticipate.mjs';
|
|
85
|
+
export { backIn, backInOut, backOut } from '../../framer-motion/dist/es/easing/back.mjs';
|
|
86
|
+
export { circIn, circInOut, circOut } from '../../framer-motion/dist/es/easing/circ.mjs';
|
|
87
|
+
export { easeIn, easeInOut, easeOut } from '../../framer-motion/dist/es/easing/ease.mjs';
|
|
88
|
+
export { cubicBezier } from '../../framer-motion/dist/es/easing/cubic-bezier.mjs';
|
|
89
|
+
export { steps } from '../../framer-motion/dist/es/easing/steps.mjs';
|
|
90
|
+
export { mirrorEasing } from '../../framer-motion/dist/es/easing/modifiers/mirror.mjs';
|
|
91
|
+
export { reverseEasing } from '../../framer-motion/dist/es/easing/modifiers/reverse.mjs';
|
|
92
|
+
export { distance, distance2D } from '../../framer-motion/dist/es/utils/distance.mjs';
|
|
93
|
+
export { invariant, warning } from '../../framer-motion/dist/es/utils/errors.mjs';
|
|
94
|
+
export { interpolate } from '../../framer-motion/dist/es/utils/interpolate.mjs';
|
|
95
|
+
export { cancelFrame, frame, frameData, frameSteps } from '../../framer-motion/dist/es/frameloop/frame.mjs';
|
|
96
|
+
export { animations } from '../../framer-motion/dist/es/motion/features/animations.mjs';
|
|
97
|
+
export { createBox } from '../../framer-motion/dist/es/projection/geometry/models.mjs';
|
|
98
|
+
export { calcLength } from '../../framer-motion/dist/es/projection/geometry/delta-calc.mjs';
|
|
99
|
+
export { filterProps } from '../../framer-motion/dist/es/render/dom/utils/filter-props.mjs';
|
|
100
|
+
export { makeUseVisualState } from '../../framer-motion/dist/es/motion/utils/use-visual-state.mjs';
|
|
101
|
+
export { isDragActive } from '../../framer-motion/dist/es/gestures/drag/utils/lock.mjs';
|
|
102
|
+
export { addPointerEvent } from '../../framer-motion/dist/es/events/add-pointer-event.mjs';
|
|
103
|
+
export { addPointerInfo } from '../../framer-motion/dist/es/events/event-info.mjs';
|
|
104
|
+
export { isMotionValue } from '../../framer-motion/dist/es/value/utils/is-motion-value.mjs';
|
|
105
|
+
export { isBrowser } from '../../framer-motion/dist/es/utils/is-browser.mjs';
|
|
106
|
+
export { useUnmountEffect } from '../../framer-motion/dist/es/utils/use-unmount-effect.mjs';
|
|
107
|
+
export { useIsomorphicLayoutEffect } from '../../framer-motion/dist/es/utils/use-isomorphic-effect.mjs';
|
|
108
|
+
export { useForceUpdate } from '../../framer-motion/dist/es/utils/use-force-update.mjs';
|
|
109
|
+
import * as namespace from '../../framer-motion/dist/es/components/Reorder/namespace.mjs';
|
|
110
|
+
export { namespace as Reorder };
|
package/dist/motion.dev.js
CHANGED
|
@@ -281,7 +281,7 @@
|
|
|
281
281
|
* This will be replaced by the build step with the latest version number.
|
|
282
282
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
283
283
|
*/
|
|
284
|
-
this.version = "11.11.
|
|
284
|
+
this.version = "11.11.13";
|
|
285
285
|
/**
|
|
286
286
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
287
287
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -4091,7 +4091,7 @@
|
|
|
4091
4091
|
* and warn against mismatches.
|
|
4092
4092
|
*/
|
|
4093
4093
|
{
|
|
4094
|
-
warnOnce(nextValue.version === "11.11.
|
|
4094
|
+
warnOnce(nextValue.version === "11.11.13", `Attempting to mix Motion versions ${nextValue.version} with 11.11.13 may not work as expected.`);
|
|
4095
4095
|
}
|
|
4096
4096
|
}
|
|
4097
4097
|
else if (isMotionValue(prevValue)) {
|