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 basics
npm run formatandnpm run lintThe details
Resolves
fixes #6508
Proposed Changes
TouchEvents because I literally couldn't test Blockly in a browser that doesn't support Pointer Events (even IE 10 mostly supports them, and we can't even test in IE11 because we no longer support it in other ways). The MouseEvent tests are also pretty useless for that reason, but it was easier to write a fake MouseEvent.Behavior Before Change
Pinch to zoom is broken because
Touch.getTouchIdentifierFromEventalways returns the string'mouse'for all pointer events, which is all events in modern browsers. The reason it always returns that is becausePointerEventis actually a subclass ofMouseEventso we always enter the first if statement.Behavior After Change
Touch.getTouchIdentifierFromEventreturnsevent.pointerIdforPointerEvents first. If somehow we don't have a PointerEvent, which is extremely unlikely, then we fall back to the old behavior of 'mouse' if it's aMouseEventand checkingchangedTouchesif it's aTouchEvent. Note that even if we have aPointerEventwhere thepointerTypeismouse, we still use thepointerIdand not the string'mouse'as that matches the old behavior from before #6099.Reason for Changes
fixes broken pinch to zoom
Test Coverage
PointerEvents as Blockly isn't actually supported in any environment that doesn't supportPointerEvents.Documentation
Additional Information
I'm 99% certain that we could change
getTouchIdentifierFromEventto simplyreturn e.pointerId, since PointerEvents are now robustly supported. But I'll leave that to #6543.