diff --git a/packages/framer-motion/package.json b/packages/framer-motion/package.json index 1b4482073b..49cd461245 100644 --- a/packages/framer-motion/package.json +++ b/packages/framer-motion/package.json @@ -96,8 +96,8 @@ }, { "path": "./dist/size-webpack-dom-max.js", - "maxSize": "30.23kB" + "maxSize": "30.24kB" } ], - "gitHead": "b0267f01c58c549a282ff3c97f0fb32ac1450668" + "gitHead": "117d3ccbed58a0e2b9cc7d2cf2585ea22643fce4" } diff --git a/packages/framer-motion/src/events/event-info.ts b/packages/framer-motion/src/events/event-info.ts index e07777d293..f8d7f121ca 100644 --- a/packages/framer-motion/src/events/event-info.ts +++ b/packages/framer-motion/src/events/event-info.ts @@ -1,20 +1,5 @@ import { EventInfo } from "./types" - -/** - * Filters out events not attached to the primary pointer (currently left mouse button) - * @param eventHandler - */ -function filterPrimaryPointer(eventHandler: EventListener): EventListener { - return (event: PointerEvent) => { - /** - * Specifically match against false here as incomplete versions of - * PointerEvents in very old browser might have it set as undefined. - */ - if (event.isPrimary !== false) { - eventHandler(event) - } - } -} +import { isPrimaryPointer } from "./utils/is-primary-pointer" export type EventListenerWithPointInfo = ( e: PointerEvent, @@ -45,6 +30,6 @@ export const wrapHandler = ( handler(event, extractEventInfo(event)) return shouldFilterPrimaryPointer - ? filterPrimaryPointer(listener) + ? (event: PointerEvent) => isPrimaryPointer(event) && listener(event) : listener } diff --git a/packages/framer-motion/src/events/utils/is-primary-pointer.ts b/packages/framer-motion/src/events/utils/is-primary-pointer.ts new file mode 100644 index 0000000000..a6bb895c3e --- /dev/null +++ b/packages/framer-motion/src/events/utils/is-primary-pointer.ts @@ -0,0 +1,6 @@ +/** + * Specifically match against false here as incomplete versions of + * PointerEvents in very old browser might have it set as undefined. + */ +export const isPrimaryPointer = (event: PointerEvent) => + event.isPrimary !== false diff --git a/packages/framer-motion/src/gestures/PanSession.ts b/packages/framer-motion/src/gestures/PanSession.ts index 87f516250c..d32a3de36e 100644 --- a/packages/framer-motion/src/gestures/PanSession.ts +++ b/packages/framer-motion/src/gestures/PanSession.ts @@ -7,6 +7,7 @@ import { Point, TransformPoint } from "../projection/geometry/types" import { pipe } from "../utils/pipe" import { distance2D } from "../utils/distance" import { frameData } from "../frameloop/data" +import { isPrimaryPointer } from "../events/utils/is-primary-pointer" /** * Passed in to pan event handlers like `onPan` the `PanInfo` object contains @@ -145,7 +146,7 @@ export class PanSession { { transformPagePoint }: PanSessionOptions = {} ) { // If we have more than one touch, don't start detecting this gesture - if (!event.isPrimary) return + if (!isPrimaryPointer(event)) return this.handlers = handlers this.transformPagePoint = transformPagePoint diff --git a/yarn.lock b/yarn.lock index b895f40e43..3a9b5a5ade 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7909,8 +7909,8 @@ __metadata: cache-loader: ^1.2.5 convert-tsconfig-paths-to-webpack-aliases: ^0.9.2 fork-ts-checker-webpack-plugin: ^6.2.0 - framer-motion: ^7.10.3 - framer-motion-3d: ^7.10.3 + framer-motion: ^8.0.0 + framer-motion-3d: ^8.0.0 path-browserify: ^1.0.1 react: ^18.2.0 react-dom: ^18.2.0 @@ -7976,14 +7976,14 @@ __metadata: languageName: unknown linkType: soft -"framer-motion-3d@^7.10.3, framer-motion-3d@workspace:packages/framer-motion-3d": +"framer-motion-3d@^8.0.0, framer-motion-3d@workspace:packages/framer-motion-3d": version: 0.0.0-use.local resolution: "framer-motion-3d@workspace:packages/framer-motion-3d" dependencies: "@react-three/fiber": ^8.2.2 "@react-three/test-renderer": ^9.0.0 "@rollup/plugin-commonjs": ^22.0.1 - framer-motion: ^7.10.3 + framer-motion: ^8.0.0 react-merge-refs: ^2.0.1 peerDependencies: "@react-three/fiber": ^8.2.2 @@ -7993,7 +7993,7 @@ __metadata: languageName: unknown linkType: soft -"framer-motion@^7.10.3, framer-motion@workspace:packages/framer-motion": +"framer-motion@^8.0.0, framer-motion@workspace:packages/framer-motion": version: 0.0.0-use.local resolution: "framer-motion@workspace:packages/framer-motion" dependencies: