Optimize and simplify the gesture system #3190
Merged
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.
Optimize and simplify the gesture system does:
Stops
GESTURE_DRAG
from triggeringGESTURE_HOLD
onUpdateGestures()
(L439-L445). "hold" is not needed for "drag". Simplifies "drag" handling while keeping its funcionality.Removes
GESTURES.Touch.eventTime
update forGESTURE_DRAG
(L336) since it no longer needs to triggerGESTURE_HOLD
onUpdateGestures()
.Removes
GESTURES.Touch.firstId
updating fromTOUCH_ACTION_DOWN
(L295). It's only used on the condition to detect aGESTURE_SWIPE
, but since its value is always zero, its achieving no purpose. It's also not needed for the "swipe" detection (L311).Removes the
GESTURES.Swipe.start
(L222, L308) and its check (L338-L343) duringTOUCH_ACTION_MOVE
. Updating it underTOUCH_ACTION_MOVE
actually causes its value to be delayed from its actual start time that happens onTOUCH_ACTION_DOWN
.Renames
GESTURES.Swipe.timeDuration
toGESTURES.Swipe.startTime
(L223-R222, R305) and moves it update to underTOUCH_ACTION_DOWN
(R294) so its time value is accurate.Decouples GESTURE_SWIPE_* from GESTURE_DRAG does:
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".
Adds another condition (
GESTURES.current
must not beGESTURE_DRAG
) to detect "swipe" (R308). Makes "drag" stop triggering a "swipe" when it ends. This is now reliable due to theGESTURES.Swipe.startTime
change (R294), that makes theGESTURES.Drag.intensity
calculation to be accurate now.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.