Add option to prevent firing multiple directions#275
Add option to prevent firing multiple directions#275vietnogi wants to merge 1 commit intoFormidableLabs:mainfrom
Conversation
|
@vietnogi Thank you for this! This is awesome and something i've also noticed before. I think this will be a great addition and possibly even be on by default, what are your thoughts? I have it added to the v7 project! Do you think you'd be able to add a test? |
|
❓ maybe off by default and change name more to its intent like
If it were the opposite and on by default:
|
hartzis
left a comment
There was a problem hiding this comment.
- Need to adjust where
initialDirectionis set to happen afterdeltacheck. - need test(s) for new functionality
moving out of v7 for now, but we can totally add this functionality after as backwards compatible 👍
| defaultProps.delta; | ||
| if (absX < delta && absY < delta && !state.swiping) return state; | ||
| if (absX < delta && absY < delta && !state.swiping) | ||
| return { ...state, initialDirection: state.initialDirection || dir }; |
There was a problem hiding this comment.
🤔 i think we'd need to actually set initialDirection outside of the catch for delta. We should probably only count the initial direction once the user has surpassed the delta which signifies the start of a "swipe" or "swiping"
Problem
User is swiping up but also to the right and firing events for swiping right causing unintentional functionality.
Use Case
User is scrolling up a list but its not straight so causing UX for swiping right.
Solution
Add add an option to prevent mix directions during a single swipe. A state for the initial direction is set and will be use to compare subsequent swipe movements. If the option is set and if the swipe direction changes, then we do not fire the event.
Before Example

After Example
