Skip to content

Lock scroll when dragged horizontally/vertically#47

Merged
ilyashubin merged 4 commits into
ilyashubin:masterfrom
alexwidua:master
Jun 7, 2020
Merged

Lock scroll when dragged horizontally/vertically#47
ilyashubin merged 4 commits into
ilyashubin:masterfrom
alexwidua:master

Conversation

@alexwidua
Copy link
Copy Markdown
Contributor

@alexwidua alexwidua commented Jun 5, 2020

Improve the interaction for mobile devices:
If lockScrollOnDragDirection is set to 'horizontal' and a horizontal drag is detected, default touch events will be prevented; if a vertical drag is detected, the drag position won't be updated.

Vice versa if lockScrollOnDragDirection is set to 'vertical', eventhough I'm not sure if there is a use case for this.

Goal is to increase UX for mobile devices since the pointerDownPreventDefault prop alone wasn't enough and the page jumps around if a scrollable element is being dragged (somewhat referencing #28)

Codesandbox Demo

@alexwidua
Copy link
Copy Markdown
Contributor Author

alexwidua commented Jun 5, 2020

Added a similar approach for trackpad (scroll) events:
If preventDefaultOnEmulateScroll is set to 'horizontal', horizontal default events will be prevented but vertical scrolling is still enabled. This is useful if you want to prevent trackpad gestures but still want to allow vertical navigation. I think this is kinda what #23 was going for.

I've updated the Codesandbox demo above.

Comment thread src/index.js Outdated
@ilyashubin
Copy link
Copy Markdown
Owner

thanks for your PR! Very useful

@ilyashubin ilyashubin merged commit d807640 into ilyashubin:master Jun 7, 2020
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.

2 participants