framer-motion 6.3.11 → 6.3.12
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/cjs/index.js +2 -20
- package/dist/es/animation/use-animated-state.mjs +0 -1
- package/dist/es/animation/utils/transitions.mjs +0 -2
- package/dist/es/context/DeprecatedLayoutGroupContext.mjs +0 -1
- package/dist/es/context/LayoutGroupContext.mjs +0 -3
- package/dist/es/motion/index.mjs +0 -2
- package/dist/es/render/utils/animation.mjs +0 -3
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -4
- package/dist/es/value/use-inverted-scale.mjs +0 -1
- package/dist/es/value/utils/resolve-motion-value.mjs +0 -2
- package/dist/framer-motion.dev.js +2 -20
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +4118 -0
- package/dist/projection.dev.js +2 -9
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/three-entry.d.ts +2428 -0
- package/package.json +4 -4
- package/types/animation/animate.d.ts +0 -54
- package/types/animation/animation-controls.d.ts +0 -5
- package/types/animation/types.d.ts +0 -79
- package/types/animation/use-animated-state.d.ts +0 -6
- package/types/animation/use-animation.d.ts +0 -31
- package/types/animation/utils/default-transitions.d.ts +0 -19
- package/types/animation/utils/easing.d.ts +0 -3
- package/types/animation/utils/is-animatable.d.ts +0 -11
- package/types/animation/utils/is-animation-controls.d.ts +0 -2
- package/types/animation/utils/is-keyframes-target.d.ts +0 -2
- package/types/animation/utils/transitions.d.ts +0 -29
- package/types/animation/utils/variant-resolvers.d.ts +0 -12
- package/types/components/AnimatePresence/PresenceChild.d.ts +0 -12
- package/types/components/AnimatePresence/index.d.ts +0 -36
- package/types/components/AnimatePresence/types.d.ts +0 -61
- package/types/components/AnimatePresence/use-presence.d.ts +0 -52
- package/types/components/AnimateSharedLayout.d.ts +0 -2
- package/types/components/LayoutGroup/index.d.ts +0 -12
- package/types/components/LazyMotion/index.d.ts +0 -38
- package/types/components/LazyMotion/types.d.ts +0 -54
- package/types/components/MotionConfig/index.d.ts +0 -25
- package/types/components/Reorder/Group.d.ts +0 -297
- package/types/components/Reorder/Item.d.ts +0 -278
- package/types/components/Reorder/index.d.ts +0 -509
- package/types/components/Reorder/types.d.ts +0 -10
- package/types/components/Reorder/utils/check-reorder.d.ts +0 -2
- package/types/context/DeprecatedLayoutGroupContext.d.ts +0 -6
- package/types/context/LayoutGroupContext.d.ts +0 -11
- package/types/context/LazyContext.d.ts +0 -7
- package/types/context/MotionConfigContext.d.ts +0 -36
- package/types/context/MotionContext/create.d.ts +0 -3
- package/types/context/MotionContext/index.d.ts +0 -9
- package/types/context/MotionContext/utils.d.ts +0 -3
- package/types/context/PresenceContext.d.ts +0 -17
- package/types/context/ReorderContext.d.ts +0 -3
- package/types/context/SwitchLayoutGroupContext.d.ts +0 -23
- package/types/events/event-info.d.ts +0 -5
- package/types/events/types.d.ts +0 -10
- package/types/events/use-dom-event.d.ts +0 -24
- package/types/events/use-pointer-event.d.ts +0 -4
- package/types/events/utils.d.ts +0 -3
- package/types/gestures/PanSession.d.ts +0 -127
- package/types/gestures/drag/VisualElementDragControls.d.ts +0 -56
- package/types/gestures/drag/types.d.ts +0 -294
- package/types/gestures/drag/use-drag-controls.d.ts +0 -74
- package/types/gestures/drag/use-drag.d.ts +0 -7
- package/types/gestures/drag/utils/constraints.d.ts +0 -77
- package/types/gestures/drag/utils/lock.d.ts +0 -4
- package/types/gestures/types.d.ts +0 -225
- package/types/gestures/use-focus-gesture.d.ts +0 -8
- package/types/gestures/use-hover-gesture.d.ts +0 -2
- package/types/gestures/use-pan-gesture.d.ts +0 -14
- package/types/gestures/use-tap-gesture.d.ts +0 -6
- package/types/gestures/utils/event-type.d.ts +0 -2
- package/types/gestures/utils/is-node-or-child.d.ts +0 -8
- package/types/index.d.ts +0 -96
- package/types/motion/features/animations.d.ts +0 -2
- package/types/motion/features/definitions.d.ts +0 -3
- package/types/motion/features/drag.d.ts +0 -2
- package/types/motion/features/gestures.d.ts +0 -2
- package/types/motion/features/layout/MeasureLayout.d.ts +0 -3
- package/types/motion/features/layout/index.d.ts +0 -2
- package/types/motion/features/layout/types.d.ts +0 -75
- package/types/motion/features/types.d.ts +0 -52
- package/types/motion/features/use-features.d.ts +0 -8
- package/types/motion/features/use-projection.d.ts +0 -3
- package/types/motion/features/viewport/observers.d.ts +0 -3
- package/types/motion/features/viewport/types.d.ts +0 -21
- package/types/motion/features/viewport/use-viewport.d.ts +0 -2
- package/types/motion/index.d.ts +0 -25
- package/types/motion/types.d.ts +0 -279
- package/types/motion/utils/VisualElementHandler.d.ts +0 -18
- package/types/motion/utils/is-forced-motion-value.d.ts +0 -2
- package/types/motion/utils/make-renderless-component.d.ts +0 -2
- package/types/motion/utils/should-inherit-variant.d.ts +0 -2
- package/types/motion/utils/use-motion-ref.d.ts +0 -8
- package/types/motion/utils/use-visual-element.d.ts +0 -6
- package/types/motion/utils/use-visual-state.d.ts +0 -14
- package/types/motion/utils/valid-prop.d.ts +0 -9
- package/types/projection/animation/mix-values.d.ts +0 -2
- package/types/projection/geometry/conversion.d.ts +0 -14
- package/types/projection/geometry/copy.d.ts +0 -13
- package/types/projection/geometry/delta-apply.d.ts +0 -37
- package/types/projection/geometry/delta-calc.d.ts +0 -10
- package/types/projection/geometry/delta-remove.d.ts +0 -20
- package/types/projection/geometry/models.d.ts +0 -5
- package/types/projection/geometry/types.d.ts +0 -29
- package/types/projection/geometry/utils.d.ts +0 -3
- package/types/projection/index.d.ts +0 -14
- package/types/projection/node/DocumentProjectionNode.d.ts +0 -108
- package/types/projection/node/HTMLProjectionNode.d.ts +0 -112
- package/types/projection/node/create-projection-node.d.ts +0 -301
- package/types/projection/node/group.d.ts +0 -7
- package/types/projection/node/id.d.ts +0 -1
- package/types/projection/node/types.d.ts +0 -136
- package/types/projection/shared/stack.d.ts +0 -17
- package/types/projection/styles/scale-border-radius.d.ts +0 -11
- package/types/projection/styles/scale-box-shadow.d.ts +0 -2
- package/types/projection/styles/scale-correction.d.ts +0 -3
- package/types/projection/styles/transform-origin.d.ts +0 -0
- package/types/projection/styles/transform.d.ts +0 -4
- package/types/projection/styles/types.d.ts +0 -9
- package/types/projection/use-instant-layout-transition.d.ts +0 -1
- package/types/projection/use-reset-projection.d.ts +0 -1
- package/types/projection/utils/each-axis.d.ts +0 -3
- package/types/projection/utils/has-transform.d.ts +0 -3
- package/types/projection/utils/measure.d.ts +0 -4
- package/types/render/dom/create-visual-element.d.ts +0 -2
- package/types/render/dom/features-animation.d.ts +0 -5
- package/types/render/dom/features-max.d.ts +0 -5
- package/types/render/dom/motion-minimal.d.ts +0 -5
- package/types/render/dom/motion-proxy.d.ts +0 -30
- package/types/render/dom/motion.d.ts +0 -25
- package/types/render/dom/types.d.ts +0 -28
- package/types/render/dom/use-render.d.ts +0 -4
- package/types/render/dom/utils/camel-to-dash.d.ts +0 -4
- package/types/render/dom/utils/create-config.d.ts +0 -8
- package/types/render/dom/utils/css-variables-conversion.d.ts +0 -22
- package/types/render/dom/utils/filter-props.d.ts +0 -4
- package/types/render/dom/utils/is-css-variable.d.ts +0 -4
- package/types/render/dom/utils/is-svg-component.d.ts +0 -2
- package/types/render/dom/utils/parse-dom-variant.d.ts +0 -6
- package/types/render/dom/utils/unit-conversion.d.ts +0 -27
- package/types/render/dom/value-types/animatable-none.d.ts +0 -1
- package/types/render/dom/value-types/defaults.d.ts +0 -9
- package/types/render/dom/value-types/dimensions.d.ts +0 -8
- package/types/render/dom/value-types/find.d.ts +0 -9
- package/types/render/dom/value-types/get-as-type.d.ts +0 -5
- package/types/render/dom/value-types/number.d.ts +0 -2
- package/types/render/dom/value-types/test.d.ts +0 -5
- package/types/render/dom/value-types/type-auto.d.ts +0 -5
- package/types/render/dom/value-types/type-int.d.ts +0 -8
- package/types/render/dom/value-types/types.d.ts +0 -4
- package/types/render/html/config-motion.d.ts +0 -3
- package/types/render/html/supported-elements.d.ts +0 -7
- package/types/render/html/types.d.ts +0 -61
- package/types/render/html/use-props.d.ts +0 -8
- package/types/render/html/utils/build-styles.d.ts +0 -5
- package/types/render/html/utils/build-transform.d.ts +0 -15
- package/types/render/html/utils/create-render-state.d.ts +0 -7
- package/types/render/html/utils/render.d.ts +0 -4
- package/types/render/html/utils/scrape-motion-values.d.ts +0 -2
- package/types/render/html/utils/transform.d.ts +0 -15
- package/types/render/html/visual-element.d.ts +0 -6
- package/types/render/index.d.ts +0 -2
- package/types/render/svg/config-motion.d.ts +0 -3
- package/types/render/svg/lowercase-elements.d.ts +0 -5
- package/types/render/svg/supported-elements.d.ts +0 -7
- package/types/render/svg/types.d.ts +0 -44
- package/types/render/svg/use-props.d.ts +0 -7
- package/types/render/svg/utils/build-attrs.d.ts +0 -8
- package/types/render/svg/utils/camel-case-attrs.d.ts +0 -4
- package/types/render/svg/utils/create-render-state.d.ts +0 -2
- package/types/render/svg/utils/path.d.ts +0 -9
- package/types/render/svg/utils/render.d.ts +0 -4
- package/types/render/svg/utils/scrape-motion-values.d.ts +0 -2
- package/types/render/svg/utils/transform-origin.d.ts +0 -6
- package/types/render/svg/visual-element.d.ts +0 -2
- package/types/render/types.d.ts +0 -113
- package/types/render/utils/animation-state.d.ts +0 -31
- package/types/render/utils/animation.d.ts +0 -21
- package/types/render/utils/compare-by-depth.d.ts +0 -5
- package/types/render/utils/flat-tree.d.ts +0 -8
- package/types/render/utils/is-draggable.d.ts +0 -2
- package/types/render/utils/lifecycles.d.ts +0 -114
- package/types/render/utils/motion-values.d.ts +0 -3
- package/types/render/utils/setters.d.ts +0 -792
- package/types/render/utils/types.d.ts +0 -9
- package/types/render/utils/variants.d.ts +0 -20
- package/types/three-entry.d.ts +0 -19
- package/types/types.d.ts +0 -981
- package/types/utils/array.d.ts +0 -3
- package/types/utils/each-axis.d.ts +0 -1
- package/types/utils/is-browser.d.ts +0 -1
- package/types/utils/is-numerical-string.d.ts +0 -4
- package/types/utils/is-ref-object.d.ts +0 -2
- package/types/utils/is-zero-value-string.d.ts +0 -4
- package/types/utils/noop.d.ts +0 -1
- package/types/utils/process.d.ts +0 -1
- package/types/utils/resolve-value.d.ts +0 -3
- package/types/utils/shallow-compare.d.ts +0 -1
- package/types/utils/subscription-manager.d.ts +0 -9
- package/types/utils/time-conversion.d.ts +0 -7
- package/types/utils/transform.d.ts +0 -91
- package/types/utils/use-animation-frame.d.ts +0 -2
- package/types/utils/use-constant.d.ts +0 -10
- package/types/utils/use-cycle.d.ts +0 -30
- package/types/utils/use-force-update.d.ts +0 -1
- package/types/utils/use-id.d.ts +0 -6
- package/types/utils/use-instant-transition-state.d.ts +0 -3
- package/types/utils/use-instant-transition.d.ts +0 -1
- package/types/utils/use-is-mounted.d.ts +0 -2
- package/types/utils/use-isomorphic-effect.d.ts +0 -2
- package/types/utils/use-reduced-motion.d.ts +0 -28
- package/types/utils/use-unmount-effect.d.ts +0 -1
- package/types/utils/warn-once.d.ts +0 -2
- package/types/value/index.d.ts +0 -260
- package/types/value/scroll/use-element-scroll.d.ts +0 -28
- package/types/value/scroll/use-viewport-scroll.d.ts +0 -22
- package/types/value/scroll/utils.d.ts +0 -19
- package/types/value/use-combine-values.d.ts +0 -2
- package/types/value/use-inverted-scale.d.ts +0 -28
- package/types/value/use-motion-template.d.ts +0 -24
- package/types/value/use-motion-value.d.ts +0 -19
- package/types/value/use-on-change.d.ts +0 -3
- package/types/value/use-spring.d.ts +0 -22
- package/types/value/use-time.d.ts +0 -1
- package/types/value/use-transform.d.ts +0 -93
- package/types/value/use-velocity.d.ts +0 -13
- package/types/value/utils/is-motion-value.d.ts +0 -2
- package/types/value/utils/resolve-motion-value.d.ts +0 -10
package/types/utils/array.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function eachAxis<T>(handler: (axis: "x" | "y") => T): T[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isBrowser: boolean;
|
package/types/utils/noop.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function noop<T>(any: T): T;
|
package/types/utils/process.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const env: string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function shallowCompare(next: any[], prev: any[] | null): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare type GenericHandler = (...args: any) => void;
|
|
2
|
-
export declare class SubscriptionManager<Handler extends GenericHandler> {
|
|
3
|
-
private subscriptions;
|
|
4
|
-
add(handler: Handler): () => void;
|
|
5
|
-
notify(a?: Parameters<Handler>[0], b?: Parameters<Handler>[1], c?: Parameters<Handler>[2]): void;
|
|
6
|
-
getSize(): number;
|
|
7
|
-
clear(): void;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Easing } from "popmotion";
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export interface TransformOptions<T> {
|
|
6
|
-
/**
|
|
7
|
-
* Clamp values to within the given range. Defaults to `true`
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
clamp?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Easing functions to use on the interpolations between each value in the input and output ranges.
|
|
14
|
-
*
|
|
15
|
-
* If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
ease?: Easing | Easing[];
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
mixer?: (from: T, to: T) => (v: number) => any;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Transforms numbers into other values by mapping them from an input range to an output range.
|
|
27
|
-
* Returns the type of the input provided.
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
*
|
|
31
|
-
* Given an input range of `[0, 200]` and an output range of
|
|
32
|
-
* `[0, 1]`, this function will return a value between `0` and `1`.
|
|
33
|
-
* The input range must be a linear series of numbers. The output range
|
|
34
|
-
* can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
|
|
35
|
-
* Every value in the output range must be of the same type and in the same format.
|
|
36
|
-
*
|
|
37
|
-
* ```jsx
|
|
38
|
-
* import * as React from "react"
|
|
39
|
-
* import { transform } from "framer-motion"
|
|
40
|
-
*
|
|
41
|
-
* export function MyComponent() {
|
|
42
|
-
* const inputRange = [0, 200]
|
|
43
|
-
* const outputRange = [0, 1]
|
|
44
|
-
* const output = transform(100, inputRange, outputRange)
|
|
45
|
-
*
|
|
46
|
-
* // Returns 0.5
|
|
47
|
-
* return <div>{output}</div>
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param inputValue - A number to transform between the input and output ranges.
|
|
52
|
-
* @param inputRange - A linear series of numbers (either all increasing or decreasing).
|
|
53
|
-
* @param outputRange - A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as `inputRange`.
|
|
54
|
-
* @param options - Clamp: Clamp values to within the given range. Defaults to `true`.
|
|
55
|
-
*
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export declare function transform<T>(inputValue: number, inputRange: number[], outputRange: T[], options?: TransformOptions<T>): T;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* Transforms numbers into other values by mapping them from an input range to an output range.
|
|
62
|
-
*
|
|
63
|
-
* Given an input range of `[0, 200]` and an output range of
|
|
64
|
-
* `[0, 1]`, this function will return a value between `0` and `1`.
|
|
65
|
-
* The input range must be a linear series of numbers. The output range
|
|
66
|
-
* can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
|
|
67
|
-
* Every value in the output range must be of the same type and in the same format.
|
|
68
|
-
*
|
|
69
|
-
* ```jsx
|
|
70
|
-
* import * as React from "react"
|
|
71
|
-
* import { Frame, transform } from "framer"
|
|
72
|
-
*
|
|
73
|
-
* export function MyComponent() {
|
|
74
|
-
* const inputRange = [-200, -100, 100, 200]
|
|
75
|
-
* const outputRange = [0, 1, 1, 0]
|
|
76
|
-
* const convertRange = transform(inputRange, outputRange)
|
|
77
|
-
* const output = convertRange(-150)
|
|
78
|
-
*
|
|
79
|
-
* // Returns 0.5
|
|
80
|
-
* return <div>{output}</div>
|
|
81
|
-
* }
|
|
82
|
-
*
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* @param inputRange - A linear series of numbers (either all increasing or decreasing).
|
|
86
|
-
* @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
|
|
87
|
-
* @param options - Clamp: clamp values to within the given range. Defaults to `true`.
|
|
88
|
-
*
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
export declare function transform<T>(inputRange: number[], outputRange: T[], options?: TransformOptions<T>): (inputValue: number) => T;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare type Init<T> = () => T;
|
|
2
|
-
/**
|
|
3
|
-
* Creates a constant value over the lifecycle of a component.
|
|
4
|
-
*
|
|
5
|
-
* Even if `useMemo` is provided an empty array as its final argument, it doesn't offer
|
|
6
|
-
* a guarantee that it won't re-run for performance reasons later on. By using `useConstant`
|
|
7
|
-
* you can ensure that initialisers don't execute twice or more.
|
|
8
|
-
*/
|
|
9
|
-
export declare function useConstant<T>(init: Init<T>): T;
|
|
10
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
declare type Cycle = (i?: number) => void;
|
|
2
|
-
declare type CycleState<T> = [T, Cycle];
|
|
3
|
-
/**
|
|
4
|
-
* Cycles through a series of visual properties. Can be used to toggle between or cycle through animations. It works similar to `useState` in React. It is provided an initial array of possible states, and returns an array of two arguments.
|
|
5
|
-
*
|
|
6
|
-
* An index value can be passed to the returned `cycle` function to cycle to a specific index.
|
|
7
|
-
*
|
|
8
|
-
* ```jsx
|
|
9
|
-
* import * as React from "react"
|
|
10
|
-
* import { motion, useCycle } from "framer-motion"
|
|
11
|
-
*
|
|
12
|
-
* export const MyComponent = () => {
|
|
13
|
-
* const [x, cycleX] = useCycle(0, 50, 100)
|
|
14
|
-
*
|
|
15
|
-
* return (
|
|
16
|
-
* <motion.div
|
|
17
|
-
* animate={{ x: x }}
|
|
18
|
-
* onTap={() => cycleX()}
|
|
19
|
-
* />
|
|
20
|
-
* )
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @param items - items to cycle through
|
|
25
|
-
* @returns [currentState, cycleState]
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare function useCycle<T>(...items: T[]): CycleState<T>;
|
|
30
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useForceUpdate(): [VoidFunction, number];
|
package/types/utils/use-id.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const useId: () => number;
|
|
2
|
-
/**
|
|
3
|
-
* Ideally we'd use the following code to support React 18 optionally.
|
|
4
|
-
* But this fairly fails in Webpack (otherwise treeshaking wouldn't work at all).
|
|
5
|
-
* Need to come up with a different way of figuring this out.
|
|
6
|
-
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useInstantTransition(): (callback: () => void) => void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
|
|
3
|
-
*
|
|
4
|
-
* This can be used to implement changes to your UI based on Reduced Motion. For instance, replacing motion-sickness inducing
|
|
5
|
-
* `x`/`y` animations with `opacity`, disabling the autoplay of background videos, or turning off parallax motion.
|
|
6
|
-
*
|
|
7
|
-
* It will actively respond to changes and re-render your components with the latest setting.
|
|
8
|
-
*
|
|
9
|
-
* ```jsx
|
|
10
|
-
* export function Sidebar({ isOpen }) {
|
|
11
|
-
* const shouldReduceMotion = useReducedMotion()
|
|
12
|
-
* const closedX = shouldReduceMotion ? 0 : "-100%"
|
|
13
|
-
*
|
|
14
|
-
* return (
|
|
15
|
-
* <motion.div animate={{
|
|
16
|
-
* opacity: isOpen ? 1 : 0,
|
|
17
|
-
* x: isOpen ? 0 : closedX
|
|
18
|
-
* }} />
|
|
19
|
-
* )
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @return boolean
|
|
24
|
-
*
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export declare function useReducedMotion(): boolean | null;
|
|
28
|
-
export declare function useReducedMotionConfig(): boolean | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useUnmountEffect(callback: () => void): void;
|
package/types/value/index.d.ts
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { SubscriptionManager } from "../utils/subscription-manager";
|
|
2
|
-
export declare type Transformer<T> = (v: T) => T;
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export declare type Subscriber<T> = (v: T) => void;
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
|
|
11
|
-
export declare type StartAnimation = (complete: () => void) => () => void;
|
|
12
|
-
/**
|
|
13
|
-
* `MotionValue` is used to track the state and velocity of motion values.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export declare class MotionValue<V = any> {
|
|
18
|
-
/**
|
|
19
|
-
* This will be replaced by the build step with the latest version number.
|
|
20
|
-
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
21
|
-
*/
|
|
22
|
-
version: string;
|
|
23
|
-
/**
|
|
24
|
-
* The current state of the `MotionValue`.
|
|
25
|
-
*
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
private current;
|
|
29
|
-
/**
|
|
30
|
-
* The previous state of the `MotionValue`.
|
|
31
|
-
*
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
private prev;
|
|
35
|
-
/**
|
|
36
|
-
* Duration, in milliseconds, since last updating frame.
|
|
37
|
-
*
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
private timeDelta;
|
|
41
|
-
/**
|
|
42
|
-
* Timestamp of the last time this `MotionValue` was updated.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
private lastUpdated;
|
|
47
|
-
/**
|
|
48
|
-
* Functions to notify when the `MotionValue` updates.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
private updateSubscribers;
|
|
53
|
-
/**
|
|
54
|
-
* Functions to notify when the velocity updates.
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
velocityUpdateSubscribers: SubscriptionManager<Subscriber<number>>;
|
|
59
|
-
/**
|
|
60
|
-
* Functions to notify when the `MotionValue` updates and `render` is set to `true`.
|
|
61
|
-
*
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
private renderSubscribers;
|
|
65
|
-
/**
|
|
66
|
-
* Add a passive effect to this `MotionValue`.
|
|
67
|
-
*
|
|
68
|
-
* A passive effect intercepts calls to `set`. For instance, `useSpring` adds
|
|
69
|
-
* a passive effect that attaches a `spring` to the latest
|
|
70
|
-
* set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.
|
|
71
|
-
*
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
|
-
private passiveEffect?;
|
|
75
|
-
/**
|
|
76
|
-
* A reference to the currently-controlling Popmotion animation
|
|
77
|
-
*
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
80
|
-
private stopAnimation?;
|
|
81
|
-
/**
|
|
82
|
-
* Tracks whether this value can output a velocity. Currently this is only true
|
|
83
|
-
* if the value is numerical, but we might be able to widen the scope here and support
|
|
84
|
-
* other value types.
|
|
85
|
-
*
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
private canTrackVelocity;
|
|
89
|
-
/**
|
|
90
|
-
* @param init - The initiating value
|
|
91
|
-
* @param config - Optional configuration options
|
|
92
|
-
*
|
|
93
|
-
* - `transformer`: A function to transform incoming values with.
|
|
94
|
-
*
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
97
|
-
constructor(init: V);
|
|
98
|
-
/**
|
|
99
|
-
* Adds a function that will be notified when the `MotionValue` is updated.
|
|
100
|
-
*
|
|
101
|
-
* It returns a function that, when called, will cancel the subscription.
|
|
102
|
-
*
|
|
103
|
-
* When calling `onChange` inside a React component, it should be wrapped with the
|
|
104
|
-
* `useEffect` hook. As it returns an unsubscribe function, this should be returned
|
|
105
|
-
* from the `useEffect` function to ensure you don't add duplicate subscribers..
|
|
106
|
-
*
|
|
107
|
-
* ```jsx
|
|
108
|
-
* export const MyComponent = () => {
|
|
109
|
-
* const x = useMotionValue(0)
|
|
110
|
-
* const y = useMotionValue(0)
|
|
111
|
-
* const opacity = useMotionValue(1)
|
|
112
|
-
*
|
|
113
|
-
* useEffect(() => {
|
|
114
|
-
* function updateOpacity() {
|
|
115
|
-
* const maxXY = Math.max(x.get(), y.get())
|
|
116
|
-
* const newOpacity = transform(maxXY, [0, 100], [1, 0])
|
|
117
|
-
* opacity.set(newOpacity)
|
|
118
|
-
* }
|
|
119
|
-
*
|
|
120
|
-
* const unsubscribeX = x.onChange(updateOpacity)
|
|
121
|
-
* const unsubscribeY = y.onChange(updateOpacity)
|
|
122
|
-
*
|
|
123
|
-
* return () => {
|
|
124
|
-
* unsubscribeX()
|
|
125
|
-
* unsubscribeY()
|
|
126
|
-
* }
|
|
127
|
-
* }, [])
|
|
128
|
-
*
|
|
129
|
-
* return <motion.div style={{ x }} />
|
|
130
|
-
* }
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
* @internalremarks
|
|
134
|
-
*
|
|
135
|
-
* We could look into a `useOnChange` hook if the above lifecycle management proves confusing.
|
|
136
|
-
*
|
|
137
|
-
* ```jsx
|
|
138
|
-
* useOnChange(x, () => {})
|
|
139
|
-
* ```
|
|
140
|
-
*
|
|
141
|
-
* @param subscriber - A function that receives the latest value.
|
|
142
|
-
* @returns A function that, when called, will cancel this subscription.
|
|
143
|
-
*
|
|
144
|
-
* @public
|
|
145
|
-
*/
|
|
146
|
-
onChange(subscription: Subscriber<V>): () => void;
|
|
147
|
-
clearListeners(): void;
|
|
148
|
-
/**
|
|
149
|
-
* Adds a function that will be notified when the `MotionValue` requests a render.
|
|
150
|
-
*
|
|
151
|
-
* @param subscriber - A function that's provided the latest value.
|
|
152
|
-
* @returns A function that, when called, will cancel this subscription.
|
|
153
|
-
*
|
|
154
|
-
* @internal
|
|
155
|
-
*/
|
|
156
|
-
onRenderRequest(subscription: Subscriber<V>): () => void;
|
|
157
|
-
/**
|
|
158
|
-
* Attaches a passive effect to the `MotionValue`.
|
|
159
|
-
*
|
|
160
|
-
* @internal
|
|
161
|
-
*/
|
|
162
|
-
attach(passiveEffect: PassiveEffect<V>): void;
|
|
163
|
-
/**
|
|
164
|
-
* Sets the state of the `MotionValue`.
|
|
165
|
-
*
|
|
166
|
-
* @remarks
|
|
167
|
-
*
|
|
168
|
-
* ```jsx
|
|
169
|
-
* const x = useMotionValue(0)
|
|
170
|
-
* x.set(10)
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* @param latest - Latest value to set.
|
|
174
|
-
* @param render - Whether to notify render subscribers. Defaults to `true`
|
|
175
|
-
*
|
|
176
|
-
* @public
|
|
177
|
-
*/
|
|
178
|
-
set(v: V, render?: boolean): void;
|
|
179
|
-
updateAndNotify: (v: V, render?: boolean) => void;
|
|
180
|
-
/**
|
|
181
|
-
* Returns the latest state of `MotionValue`
|
|
182
|
-
*
|
|
183
|
-
* @returns - The latest state of `MotionValue`
|
|
184
|
-
*
|
|
185
|
-
* @public
|
|
186
|
-
*/
|
|
187
|
-
get(): V;
|
|
188
|
-
/**
|
|
189
|
-
* @public
|
|
190
|
-
*/
|
|
191
|
-
getPrevious(): V;
|
|
192
|
-
/**
|
|
193
|
-
* Returns the latest velocity of `MotionValue`
|
|
194
|
-
*
|
|
195
|
-
* @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
|
|
196
|
-
*
|
|
197
|
-
* @public
|
|
198
|
-
*/
|
|
199
|
-
getVelocity(): number;
|
|
200
|
-
/**
|
|
201
|
-
* Schedule a velocity check for the next frame.
|
|
202
|
-
*
|
|
203
|
-
* This is an instanced and bound function to prevent generating a new
|
|
204
|
-
* function once per frame.
|
|
205
|
-
*
|
|
206
|
-
* @internal
|
|
207
|
-
*/
|
|
208
|
-
private scheduleVelocityCheck;
|
|
209
|
-
/**
|
|
210
|
-
* Updates `prev` with `current` if the value hasn't been updated this frame.
|
|
211
|
-
* This ensures velocity calculations return `0`.
|
|
212
|
-
*
|
|
213
|
-
* This is an instanced and bound function to prevent generating a new
|
|
214
|
-
* function once per frame.
|
|
215
|
-
*
|
|
216
|
-
* @internal
|
|
217
|
-
*/
|
|
218
|
-
private velocityCheck;
|
|
219
|
-
hasAnimated: boolean;
|
|
220
|
-
/**
|
|
221
|
-
* Registers a new animation to control this `MotionValue`. Only one
|
|
222
|
-
* animation can drive a `MotionValue` at one time.
|
|
223
|
-
*
|
|
224
|
-
* ```jsx
|
|
225
|
-
* value.start()
|
|
226
|
-
* ```
|
|
227
|
-
*
|
|
228
|
-
* @param animation - A function that starts the provided animation
|
|
229
|
-
*
|
|
230
|
-
* @internal
|
|
231
|
-
*/
|
|
232
|
-
start(animation: StartAnimation): Promise<void>;
|
|
233
|
-
/**
|
|
234
|
-
* Stop the currently active animation.
|
|
235
|
-
*
|
|
236
|
-
* @public
|
|
237
|
-
*/
|
|
238
|
-
stop(): void;
|
|
239
|
-
/**
|
|
240
|
-
* Returns `true` if this value is currently animating.
|
|
241
|
-
*
|
|
242
|
-
* @public
|
|
243
|
-
*/
|
|
244
|
-
isAnimating(): boolean;
|
|
245
|
-
private clearAnimation;
|
|
246
|
-
/**
|
|
247
|
-
* Destroy and clean up subscribers to this `MotionValue`.
|
|
248
|
-
*
|
|
249
|
-
* The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
|
|
250
|
-
* handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
|
|
251
|
-
* created a `MotionValue` via the `motionValue` function.
|
|
252
|
-
*
|
|
253
|
-
* @public
|
|
254
|
-
*/
|
|
255
|
-
destroy(): void;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* @internal
|
|
259
|
-
*/
|
|
260
|
-
export declare function motionValue<V>(init: V): MotionValue<V>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { RefObject } from "react";
|
|
2
|
-
import { ScrollMotionValues } from "./utils";
|
|
3
|
-
/**
|
|
4
|
-
* Returns MotionValues that update when the provided element scrolls:
|
|
5
|
-
*
|
|
6
|
-
* - `scrollX` — Horizontal scroll distance in pixels.
|
|
7
|
-
* - `scrollY` — Vertical scroll distance in pixels.
|
|
8
|
-
* - `scrollXProgress` — Horizontal scroll progress between `0` and `1`.
|
|
9
|
-
* - `scrollYProgress` — Vertical scroll progress between `0` and `1`.
|
|
10
|
-
*
|
|
11
|
-
* This element must be set to `overflow: scroll` on either or both axes to report scroll offset.
|
|
12
|
-
*
|
|
13
|
-
* ```jsx
|
|
14
|
-
* export const MyComponent = () => {
|
|
15
|
-
* const ref = useRef()
|
|
16
|
-
* const { scrollYProgress } = useElementScroll(ref)
|
|
17
|
-
*
|
|
18
|
-
* return (
|
|
19
|
-
* <div ref={ref}>
|
|
20
|
-
* <motion.div style={{ scaleX: scrollYProgress }} />
|
|
21
|
-
* </div>
|
|
22
|
-
* )
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export declare function useElementScroll(ref: RefObject<HTMLElement>): ScrollMotionValues;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ScrollMotionValues } from "./utils";
|
|
2
|
-
/**
|
|
3
|
-
* Returns MotionValues that update when the viewport scrolls:
|
|
4
|
-
*
|
|
5
|
-
* - `scrollX` — Horizontal scroll distance in pixels.
|
|
6
|
-
* - `scrollY` — Vertical scroll distance in pixels.
|
|
7
|
-
* - `scrollXProgress` — Horizontal scroll progress between `0` and `1`.
|
|
8
|
-
* - `scrollYProgress` — Vertical scroll progress between `0` and `1`.
|
|
9
|
-
*
|
|
10
|
-
* **Warning:** Setting `body` or `html` to `height: 100%` or similar will break the `Progress`
|
|
11
|
-
* values as this breaks the browser's capability to accurately measure the page length.
|
|
12
|
-
*
|
|
13
|
-
* ```jsx
|
|
14
|
-
* export const MyComponent = () => {
|
|
15
|
-
* const { scrollYProgress } = useViewportScroll()
|
|
16
|
-
* return <motion.div style={{ scaleX: scrollYProgress }} />
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare function useViewportScroll(): ScrollMotionValues;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MotionValue } from "../";
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export interface ScrollMotionValues {
|
|
6
|
-
scrollX: MotionValue<number>;
|
|
7
|
-
scrollY: MotionValue<number>;
|
|
8
|
-
scrollXProgress: MotionValue<number>;
|
|
9
|
-
scrollYProgress: MotionValue<number>;
|
|
10
|
-
}
|
|
11
|
-
export interface ScrollOffsets {
|
|
12
|
-
xOffset: number;
|
|
13
|
-
yOffset: number;
|
|
14
|
-
xMaxOffset: number;
|
|
15
|
-
yMaxOffset: number;
|
|
16
|
-
}
|
|
17
|
-
export declare type GetScrollOffsets = () => ScrollOffsets;
|
|
18
|
-
export declare function createScrollMotionValues(): ScrollMotionValues;
|
|
19
|
-
export declare function createScrollUpdater(values: ScrollMotionValues, getOffsets: GetScrollOffsets): () => void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { MotionValue } from "./";
|
|
2
|
-
interface ScaleMotionValues {
|
|
3
|
-
scaleX: MotionValue<number>;
|
|
4
|
-
scaleY: MotionValue<number>;
|
|
5
|
-
}
|
|
6
|
-
export declare const invertScale: (scale: number) => number;
|
|
7
|
-
/**
|
|
8
|
-
* Returns a `MotionValue` each for `scaleX` and `scaleY` that update with the inverse
|
|
9
|
-
* of their respective parent scales.
|
|
10
|
-
*
|
|
11
|
-
* This is useful for undoing the distortion of content when scaling a parent component.
|
|
12
|
-
*
|
|
13
|
-
* By default, `useInvertedScale` will automatically fetch `scaleX` and `scaleY` from the nearest parent.
|
|
14
|
-
* By passing other `MotionValue`s in as `useInvertedScale({ scaleX, scaleY })`, it will invert the output
|
|
15
|
-
* of those instead.
|
|
16
|
-
*
|
|
17
|
-
* ```jsx
|
|
18
|
-
* const MyComponent = () => {
|
|
19
|
-
* const { scaleX, scaleY } = useInvertedScale()
|
|
20
|
-
* return <motion.div style={{ scaleX, scaleY }} />
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @deprecated
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
export declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMotionValues;
|
|
28
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MotionValue } from ".";
|
|
2
|
-
/**
|
|
3
|
-
* Combine multiple motion values into a new one using a string template literal.
|
|
4
|
-
*
|
|
5
|
-
* ```jsx
|
|
6
|
-
* import {
|
|
7
|
-
* motion,
|
|
8
|
-
* useSpring,
|
|
9
|
-
* useMotionValue,
|
|
10
|
-
* useMotionTemplate
|
|
11
|
-
* } from "framer-motion"
|
|
12
|
-
*
|
|
13
|
-
* function Component() {
|
|
14
|
-
* const shadowX = useSpring(0)
|
|
15
|
-
* const shadowY = useMotionValue(0)
|
|
16
|
-
* const shadow = useMotionTemplate`drop-shadow(${shadowX}px ${shadowY}px 20px rgba(0,0,0,0.3))`
|
|
17
|
-
*
|
|
18
|
-
* return <motion.div style={{ filter: shadow }} />
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export declare function useMotionTemplate(fragments: TemplateStringsArray, ...values: MotionValue[]): MotionValue<string>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { MotionValue } from ".";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a `MotionValue` to track the state and velocity of a value.
|
|
4
|
-
*
|
|
5
|
-
* 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.
|
|
6
|
-
*
|
|
7
|
-
* ```jsx
|
|
8
|
-
* export const MyComponent = () => {
|
|
9
|
-
* const scale = useMotionValue(1)
|
|
10
|
-
*
|
|
11
|
-
* return <motion.div style={{ scale }} />
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* @param initial - The initial state.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export declare function useMotionValue<T>(initial: T): MotionValue<T>;
|