framer-motion 5.2.0 → 5.3.1

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.
Files changed (39) hide show
  1. package/dist/es/animation/utils/transitions.mjs +8 -2
  2. package/dist/es/components/Reorder/Item.mjs +4 -3
  3. package/dist/es/gestures/use-hover-gesture.mjs +4 -1
  4. package/dist/es/gestures/use-tap-gesture.mjs +4 -1
  5. package/dist/es/index.mjs +1 -0
  6. package/dist/es/motion/features/definitions.mjs +6 -0
  7. package/dist/es/motion/features/gestures.mjs +2 -0
  8. package/dist/es/motion/features/viewport/observers.mjs +52 -0
  9. package/dist/es/motion/features/viewport/use-viewport.mjs +97 -0
  10. package/dist/es/motion/utils/use-visual-state.mjs +29 -10
  11. package/dist/es/motion/utils/valid-prop.mjs +5 -0
  12. package/dist/es/projection/node/create-projection-node.mjs +1 -1
  13. package/dist/es/render/dom/utils/unit-conversion.mjs +8 -1
  14. package/dist/es/render/utils/animation-state.mjs +7 -4
  15. package/dist/es/render/utils/setters.mjs +1 -3
  16. package/dist/es/render/utils/types.mjs +1 -0
  17. package/dist/es/utils/use-instant-transition-state.mjs +5 -0
  18. package/dist/es/utils/use-instant-transition.mjs +28 -0
  19. package/dist/es/utils/warn-once.mjs +11 -0
  20. package/dist/framer-motion.cjs.js +259 -33
  21. package/dist/framer-motion.dev.js +259 -33
  22. package/dist/framer-motion.js +1 -1
  23. package/dist/projection.dev.js +29 -8
  24. package/dist/size-rollup-dom-animation.js +1 -1
  25. package/dist/size-rollup-dom-max.js +1 -1
  26. package/dist/size-rollup-m.js +1 -1
  27. package/package.json +11 -11
  28. package/types/components/Reorder/Item.d.ts +1 -1
  29. package/types/index.d.ts +1 -0
  30. package/types/motion/features/types.d.ts +2 -0
  31. package/types/motion/features/viewport/observers.d.ts +3 -0
  32. package/types/motion/features/viewport/types.d.ts +20 -0
  33. package/types/motion/features/viewport/use-viewport.d.ts +2 -0
  34. package/types/motion/types.d.ts +2 -1
  35. package/types/render/utils/animation-state.d.ts +1 -1
  36. package/types/render/utils/types.d.ts +1 -0
  37. package/types/utils/use-instant-transition-state.d.ts +3 -0
  38. package/types/utils/use-instant-transition.d.ts +1 -0
  39. package/types/utils/warn-once.d.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framer-motion",
3
- "version": "5.2.0",
3
+ "version": "5.3.1",
4
4
  "description": "A simple and powerful React animation library",
5
5
  "main": "dist/framer-motion.cjs.js",
6
6
  "module": "dist/es/index.mjs",
@@ -37,11 +37,11 @@
37
37
  "test-ci": "yarn test-client && yarn test-server",
38
38
  "test-client": "jest --coverage --config jest.config.json --max-workers=2",
39
39
  "test-server": "jest --config jest.config.ssr.json",
40
- "test-projection": "yarn run collect-projection-tests && start-server-and-test 'python -m SimpleHTTPServer' http://localhost:8000 'yarn run cypress run -s cypress/integration/projection.chrome.ts --config baseUrl=http://0.0.0.0:8000/'",
40
+ "test-projection": "yarn run collect-projection-tests && start-server-and-test 'python -m SimpleHTTPServer' http://0.0.0.0:8000 'yarn run cypress run -s cypress/integration/projection.chrome.ts --config baseUrl=http://localhost:8000/'",
41
41
  "test-e2e-chrome": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --browser chrome --spec \"cypress/integration/layout-relative.chrome.ts\"'",
42
42
  "test-e2e-electron": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --config ignoreTestFiles=*.chrome.ts'",
43
- "test-e2e": "yarn test-e2e-chrome && yarn test-e2e-electron",
44
- "test-e2e-file": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --spec \"cypress/integration/drag-framer-page.ts\"'",
43
+ "test-e2e": "yarn test-e2e-electron",
44
+ "test-e2e-file": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --spec \"cypress/integration/while-in-view.ts\"'",
45
45
  "test-watch": "jest --watch --coverage --coverageReporters=lcov --config jest.config.json",
46
46
  "projection-dev": "python -m SimpleHTTPServer",
47
47
  "collect-projection-tests": "node ./dev/projection/collect-projection-tests.js",
@@ -136,31 +136,31 @@
136
136
  "bundlesize": [
137
137
  {
138
138
  "path": "./dist/framer-motion.js",
139
- "maxSize": "34.1 kB"
139
+ "maxSize": "34.8 kB"
140
140
  },
141
141
  {
142
142
  "path": "./dist/size-rollup-m.js",
143
- "maxSize": "6.5 kB"
143
+ "maxSize": "6.0 kB"
144
144
  },
145
145
  {
146
146
  "path": "./dist/size-rollup-dom-animation.js",
147
- "maxSize": "17.2 kB"
147
+ "maxSize": "16.9 kB"
148
148
  },
149
149
  {
150
150
  "path": "./dist/size-rollup-dom-max.js",
151
- "maxSize": "28.1 kB"
151
+ "maxSize": "27.9 kB"
152
152
  },
153
153
  {
154
154
  "path": "./dist/size-webpack-m.js",
155
- "maxSize": "6.5 kB"
155
+ "maxSize": "6.3 kB"
156
156
  },
157
157
  {
158
158
  "path": "./dist/size-webpack-dom-animation.js",
159
- "maxSize": "19 kB"
159
+ "maxSize": "19.4 kB"
160
160
  },
161
161
  {
162
162
  "path": "./dist/size-webpack-dom-max.js",
163
- "maxSize": "30.4 kB"
163
+ "maxSize": "31 kB"
164
164
  }
165
165
  ]
166
166
  }
@@ -15,7 +15,7 @@ export interface Props<V> {
15
15
  */
16
16
  value: V;
17
17
  }
18
- export declare function ReorderItem<V>({ children, style, value, as, ...props }: Props<V> & HTMLMotionProps<any> & React.PropsWithChildren<{}>, externalRef?: React.Ref<any>): JSX.Element;
18
+ export declare function ReorderItem<V>({ children, style, value, as, onDrag, ...props }: Props<V> & HTMLMotionProps<any> & React.PropsWithChildren<{}>, externalRef?: React.Ref<any>): JSX.Element;
19
19
  export declare const Item: React.ForwardRefExoticComponent<Props<unknown> & {
20
20
  color?: string | undefined;
21
21
  translate?: "no" | "yes" | undefined;
package/types/index.d.ts CHANGED
@@ -50,6 +50,7 @@ export { createMotionComponent } from "./motion";
50
50
  export { visualElement } from "./render";
51
51
  export { VisualElement } from "./render/types";
52
52
  export { addScaleCorrector } from "./projection/styles/scale-correction";
53
+ export { useInstantTransition } from "./utils/use-instant-transition";
53
54
  export { useInstantLayoutTransition } from "./projection/use-instant-layout-transition";
54
55
  export { useResetProjection } from "./projection/use-reset-projection";
55
56
  /**
@@ -16,6 +16,7 @@ export declare type FeatureNames = {
16
16
  focus: true;
17
17
  hover: true;
18
18
  pan: true;
19
+ inView: true;
19
20
  measureLayout: true;
20
21
  };
21
22
  export declare type FeatureComponent = React.ComponentType<FeatureProps>;
@@ -34,6 +35,7 @@ export interface FeatureComponents {
34
35
  focus?: FeatureComponent;
35
36
  hover?: FeatureComponent;
36
37
  pan?: FeatureComponent;
38
+ inView?: FeatureComponent;
37
39
  measureLayout?: FeatureComponent;
38
40
  }
39
41
  export interface FeatureBundle extends FeatureComponents {
@@ -0,0 +1,3 @@
1
+ declare type IntersectionHandler = (entry: IntersectionObserverEntry) => void;
2
+ export declare function observeIntersection(element: Element, options: IntersectionObserverInit, callback: IntersectionHandler): () => void;
3
+ export {};
@@ -0,0 +1,20 @@
1
+ import { RefObject } from "react";
2
+ import { TargetAndTransition } from "../../../types";
3
+ import { VariantLabels } from "../../types";
4
+ export declare type ViewportEventHandler = () => void;
5
+ export interface ViewportOptions {
6
+ root?: RefObject<Element>;
7
+ once?: boolean;
8
+ margin?: string;
9
+ amount?: "some" | "all" | number;
10
+ }
11
+ export interface ViewportProps {
12
+ whileInView?: VariantLabels | TargetAndTransition;
13
+ onViewportEnter?: ViewportEventHandler;
14
+ onViewportLeave?: ViewportEventHandler;
15
+ viewport?: ViewportOptions;
16
+ }
17
+ export declare type ViewportState = {
18
+ hasEnteredView: boolean;
19
+ isInView: boolean;
20
+ };
@@ -0,0 +1,2 @@
1
+ import { FeatureProps } from "../types";
2
+ export declare function useViewport({ visualElement, whileInView, onViewportEnter, onViewportLeave, viewport, }: FeatureProps): void;
@@ -7,6 +7,7 @@ import { LayoutProps } from "./features/layout/types";
7
7
  import { ResolvedValues } from "../render/types";
8
8
  import { VisualElementLifecycles } from "../render/utils/lifecycles";
9
9
  import { PanHandlers, TapHandlers, HoverHandlers, FocusHandlers } from "../gestures/types";
10
+ import { ViewportProps } from "./features/viewport/types";
10
11
  export declare type MotionStyleProp = string | number | MotionValue;
11
12
  /**
12
13
  * Either a string, or array of strings, that reference variants defined via the `variants` prop.
@@ -206,7 +207,7 @@ export interface MotionAdvancedProps {
206
207
  *
207
208
  * @public
208
209
  */
209
- export interface MotionProps extends AnimationProps, VisualElementLifecycles, PanHandlers, TapHandlers, HoverHandlers, FocusHandlers, DraggableProps, LayoutProps, MotionAdvancedProps {
210
+ export interface MotionProps extends AnimationProps, VisualElementLifecycles, PanHandlers, TapHandlers, HoverHandlers, FocusHandlers, ViewportProps, DraggableProps, LayoutProps, MotionAdvancedProps {
210
211
  /**
211
212
  * Properties, variant label or array of variant labels to start in.
212
213
  *
@@ -15,7 +15,7 @@ export interface AnimationState {
15
15
  export declare type AnimationList = string[] | TargetAndTransition[];
16
16
  export declare const variantPriorityOrder: AnimationType[];
17
17
  export declare function createAnimationState(visualElement: VisualElement): AnimationState;
18
- export declare function variantsHaveChanged(prev: any, next: any): boolean;
18
+ export declare function checkVariantsDidChange(prev: any, next: any): boolean;
19
19
  export interface AnimationTypeState {
20
20
  isActive: boolean;
21
21
  protectedKeys: {
@@ -4,5 +4,6 @@ export declare enum AnimationType {
4
4
  Tap = "whileTap",
5
5
  Drag = "whileDrag",
6
6
  Focus = "whileFocus",
7
+ InView = "whileInView",
7
8
  Exit = "exit"
8
9
  }
@@ -0,0 +1,3 @@
1
+ export declare const instantAnimationState: {
2
+ current: boolean;
3
+ };
@@ -0,0 +1 @@
1
+ export declare function useInstantTransition(): (callback: () => void) => void;
@@ -0,0 +1,2 @@
1
+ export declare function hasWarned(message: string): boolean;
2
+ export declare function warnOnce(condition: boolean, message: string, element?: Element): void;