Fix touches being empty in touchEnded() by using changedTouches#8601
Open
suhr25 wants to merge 1 commit intoprocessing:mainfrom
Open
Fix touches being empty in touchEnded() by using changedTouches#8601suhr25 wants to merge 1 commit intoprocessing:mainfrom
suhr25 wants to merge 1 commit intoprocessing:mainfrom
Conversation
During a touchend event the W3C Touch Events spec moves the lifted finger out of e.touches (active contacts only) and into e.changedTouches. _updateTouchCoords iterated over e.touches.length, which is 0 when the last finger lifts, so touches[] was always empty inside touchEnded(). Fall back to e.changedTouches when e.touches is empty so that the final touch position is accessible to user code in touchEnded(). getTouchInfo already contained the e.touches[i] || e.changedTouches[i] fallback for individual lookups; this change fixes the loop bound that prevented it from being reached. Fixes: touches[] always being [] inside touchEnded() on single-touch
Author
|
Hi @davepagurek, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SUMMARY
Fixes
touchEnded()getting an emptytouches[].Now uses
changedToucheswhentouchesis empty (per spec).Changes in
src/events/touch.js+ a small unit test.FIX
e.touchesis empty ontouchend, so loop never runse.changedTouchesBefore
After
VERIFICATION
Before: 0
After: 1 (correct final touch)