New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing support for mouse and touch events #1750
Conversation
packages/framer-motion/package.json
Outdated
@@ -73,31 +73,31 @@ | |||
"bundlesize": [ | |||
{ | |||
"path": "./dist/size-rollup-motion.js", | |||
"maxSize": "29.40 kB" | |||
"maxSize": "29.12 kB" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is the "real" saving - the others saw a similar decrease with the class
PR and are likely from a previous PR.
@@ -1,6 +1,6 @@ | |||
import "@testing-library/jest-dom" | |||
// Get fireEvent from the native testing library | |||
// because @testing-library/react one switches out mouseEnter and mouseLeave | |||
// because @testing-library/react one switches out pointerEnter and pointerLeave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true for pointerEnter and pointerLeave too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the logic cleanup, but think that for the size saving it's almost not worth the effort.
Don't feel strongly though.
@@ -1,6 +1,6 @@ | |||
import "@testing-library/jest-dom" | |||
// Get fireEvent from the native testing library | |||
// because @testing-library/react one switches out mouseEnter and mouseLeave | |||
// because @testing-library/react one switches out pointerEnter and pointerLeave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
export const pointerEnter = (element: Element) => | ||
act(() => { | ||
fireEvent.mouseEnter(element) | ||
fireEvent.pointerEnter(element) | ||
}) | ||
export const mouseLeave = (element: Element) => | ||
export const pointerLeave = (element: Element) => | ||
act(() => { | ||
fireEvent.mouseLeave(element) | ||
fireEvent.pointerLeave(element) | ||
}) | ||
export const mouseDown = (element: Element) => | ||
export const pointerDown = (element: Element) => | ||
act(() => { | ||
fireEvent.mouseDown(element) | ||
fireEvent.pointerDown(element) | ||
}) | ||
export const mouseUp = (element: Element) => | ||
export const pointerUp = (element: Element) => | ||
act(() => { | ||
fireEvent.mouseUp(element) | ||
fireEvent.pointerUp(element) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these are now unused and we can just remove this whole file.
// If we have more than one touch, don't start detecting this gesture | ||
if (isTouchEvent(event) && event.touches.length > 1) return | ||
if (!event.isPrimary) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just remove this completely
// Because Safari doesn't trigger mouseup events when it's above a `<select>` | ||
if (isMouseEvent(event) && event.buttons === 0) { | ||
if (event.isPrimary) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is probably no longer true, and I wonder if we should keep the logic
5c4a633
to
22a2d71
Compare
Pointer events are extremely well supported, this PR removes support for mouse and touch event fallbacks. Saves almost 0.3kb from the
motion
component.