Prevent false positive in secondary axis for gestures #343
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.
The problem:
This PR fixes the first problem by passing both x and y movement to Gesture classes as primary and secondary axis. Then each Gesture classes can add their own logic to determine whether itself is the indented gesture or not.
New behavior of each type of gestures:
This PR fixes the second problem trivially by only increasing
_axis
when primary axis movement is positive.I've also made noneAction trigger even if some threshold are met as long as no actions have been performed by any of the gesture. This let me set the threshold to 1 for my interval gestures. I also think this makes more sense.
The behavior for scroll wheel should be unmodified though I have not tested this.Edit: The behavior for scroll wheel is unchanged. The thumb wheel was broken for interval > 8 because press() was called immediately before move(). I removed that line to fix it.
I marked this PR previously as Help Wanted because I am not sure about the desirable behavior for AxisGesture. I'm concerned about the rare (possibly non existent) use case of mapping Left to a AxisGesture and Right to something else such as a ReleaseGesture or even an IntervalGesture. Should I make it similar to IntervalGesture where only positive movement will be recorded? Should I add false positive prevention like I did in IntervalGesture? What is the indented use case for this gesture? What's @PixlOne and everyone else's opinion on this?
Edit: For now I'll be leaving AxisGesture's behavior unchanged as I don't know its common use case and don't want to break someone else's workflow. Personally I think we should make it similar to IntervalGesture (i.e. only record positive movement and have false positive prevention) for consistency sake. However, I'm open to suggestions.
Thank you