-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fix error in touchmove event #145
Conversation
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.
Thank you @maurispalletti for the PR. I'd like to take some time and think about this a bit.
I don't quite know if this is a good or bad addtion or even needed.
Mainly since the callback provides the full event
now, users could just check for event.cancelable
themselves then call preventDefault()
when they deem appropriate.
Example PR of this is the upgrade i made for react-image-gallery
:
src/__tests__/index.spec.js
Outdated
@@ -210,16 +211,17 @@ function setupGetMountedComponent(TYPE, mockListeners = mockListenersSetup) { | |||
it('calls preventDefault when onSwiping is present', () => { | |||
const onSwiping = jest.fn() | |||
const preventDefault = jest.fn() | |||
const cancelable = jest.fn() |
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.
💡 mind updating this and the other test usage to boolean
's? const cancelable = true
?
https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable
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.
Sure, my bad. I'll change it now and update the PR.
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.
PR updated!
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.
Thanks for updating the tests.
Still contemplating this change though.
Since you made the PR i'm assuming you are in favor of react-swipeable
performing this check, can you think of any down sides? or potential issues?
@hartzis, I haven't found any potential issues. It just helps to avoid that console error. |
@maurispalletti I like your thinking! I'm also very comfortable with browser support. Let's merge and publish this. |
Fix issue #128 .
e.cancelable validation added to e.preventDefault(), to avoid console error
Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.
.