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

Optimize and simplify the gesture system #3190

Merged
merged 2 commits into from Jul 22, 2023
Merged

Optimize and simplify the gesture system #3190

merged 2 commits into from Jul 22, 2023

Conversation

ghost
Copy link

@ghost ghost commented Jul 21, 2023

Optimize and simplify the gesture system does:

  1. Stops GESTURE_DRAG from triggering GESTURE_HOLD on UpdateGestures() (L439-L445). "hold" is not needed for "drag". Simplifies "drag" handling while keeping its funcionality.

  2. Removes GESTURES.Touch.eventTime update for GESTURE_DRAG (L336) since it no longer needs to trigger GESTURE_HOLD on UpdateGestures().

  3. Removes GESTURES.Touch.firstId updating from TOUCH_ACTION_DOWN (L295). It's only used on the condition to detect a GESTURE_SWIPE, but since its value is always zero, its achieving no purpose. It's also not needed for the "swipe" detection (L311).

  4. Removes the GESTURES.Swipe.start (L222, L308) and its check (L338-L343) during TOUCH_ACTION_MOVE. Updating it under TOUCH_ACTION_MOVE actually causes its value to be delayed from its actual start time that happens on TOUCH_ACTION_DOWN.

  5. Renames GESTURES.Swipe.timeDuration to GESTURES.Swipe.startTime (L223-R222, R305) and moves it update to under TOUCH_ACTION_DOWN (R294) so its time value is accurate.

Decouples GESTURE_SWIPE_* from GESTURE_DRAG does:

  1. Makes the "time" method the standard way to detect "drag" (R342). Makes its detection more consistent. Also makes its detection no longer compete with "swipe".

  2. Adds another condition (GESTURES.current must not be GESTURE_DRAG) to detect "swipe" (R308). Makes "drag" stop triggering a "swipe" when it ends. This is now reliable due to the GESTURES.Swipe.startTime change (R294), that makes the GESTURES.Drag.intensity calculation to be accurate now.

  3. Tweaks the DRAG_TIMEOUT value (R183).

Tested these changes successfully on Firefox (115.0.1) and Chrome (95.0.4638.74) for Android; Firefox (102.11.0esr 64-bit) and Chrome (114.0.5735.106 64-bit) with Touch Emulation enabled and disabled for Linux; and native on Linux.

Edit 1: added line marks of the proposed changes.
Edit 2: added the second commit.

@raysan5 raysan5 merged commit 295e8c2 into raysan5:master Jul 22, 2023
12 checks passed
@raysan5
Copy link
Owner

raysan5 commented Jul 22, 2023

@ubkp Thanks for another great improvement and for the very detailed PR description! Really great work, congratulations!

I love the PRs that remove more code than adding new one! 😄

@ghost
Copy link
Author

ghost commented Jul 22, 2023

@raysan5 Thank you :)

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.

1 participant