Skip to content
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

Merged
merged 5 commits into from Dec 21, 2022
Merged

Conversation

mattgperry
Copy link
Collaborator

@mattgperry mattgperry commented Nov 2, 2022

Pointer events are extremely well supported, this PR removes support for mouse and touch event fallbacks. Saves almost 0.3kb from the motion component.

@mattgperry mattgperry requested a review from nvh November 2, 2022 16:08
@@ -73,31 +73,31 @@
"bundlesize": [
{
"path": "./dist/size-rollup-motion.js",
"maxSize": "29.40 kB"
"maxSize": "29.12 kB"
Copy link
Collaborator Author

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
Copy link
Contributor

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?

Copy link
Contributor

@nvh nvh left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines 21 to 35
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)
Copy link
Contributor

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.

Comment on lines 145 to +148
// 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
Copy link
Contributor

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

Comment on lines 202 to 205
// Because Safari doesn't trigger mouseup events when it's above a `<select>`
if (isMouseEvent(event) && event.buttons === 0) {
if (event.isPrimary) {
Copy link
Contributor

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

@mattgperry mattgperry added the automerge Land this PR label Dec 21, 2022
@mergetron mergetron bot merged commit 2a3c406 into main Dec 21, 2022
@mergetron mergetron bot deleted the fix/pointer-events branch December 21, 2022 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Land this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants