Make preventScrollOnSwipe
option more configurable with a function
#361
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This may be something that would inherently be able to fix #275, but in my application, I use this for a carousel component. We noticed when swiping on the carousel, the page would scroll which was a bit undesirable. I eventually added
preventScrollOnSwipe
, but this made scrolling the page very hard because our carousels may take up a decent amount of the screen real estate.We would like to prevent scrolling only when a swipe on the x-axis is in progress. I considered making
preventScrollOnSwipe
have a type ofboolean | 'vertical' | 'horizontal'
but ultimately landed on this change which should allow for any custom functionality one might want before callingevent.preventDefault()
.Type of Change
How Has This Been Tested?
Tested by linking this node module in my project, and using the function. Also wrote unit tests.
Checklist: (Feel free to delete this section upon completion)