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

Add Touch Events to Callbacks #269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lightninglu10
Copy link

This PR adds touchevents to the onSliderDragStart callback. This is useful so we can control touch events through rheostat.

An example would be blocking rheostat from scrolling vertically on mobile while it's dragging. Currently if a user uses our rheostat component on mobile, they can drag the slider and scroll the page at the same time.

Also added the current passive: false touch listeners to remove the warning from chrome.

@@ -464,14 +465,14 @@ class Rheostat extends React.Component {
this.setStartSlide(ev, ev.clientX, ev.clientY);

if (typeof document.addEventListener === 'function') {
document.addEventListener('mousemove', this.handleMouseSlide, false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens with this change in browsers that don't support passive event listeners?

@albertstill
Copy link
Contributor

Be interested to know how Airbnb solve vertical scrolling issues, seems they use the exact same component as open source, I checked their source. They stop vertical scroll of the page when the user is sliding the slider horizontally, but they also allow a vertical scroll of the page if the user touches the handle accidentally when scrolling vertically.

ezgif-6-64b34f92b1cb

@albertstill
Copy link
Contributor

albertstill commented May 21, 2020

I think Airbnb stop vertical scrolling with touch (if the initial movement is horizontal) for the whole of their filters modal.

@lightninglu10 I fixed it for my site doing touch-action: pan-y on the handle, worked well and has pretty good browser support. Maybe Airbnb should consider adding this css decl to this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants