-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix #9393: Consistent _buttonDown usage in ScreenSpaceEventHandler.js #12613
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
Open
ayushd150
wants to merge
2
commits into
CesiumGS:main
Choose a base branch
from
ayushd150:fix/9393-buttondown-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,5 +42,8 @@ | |
"directories": {}, | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
}, | ||
"dependencies": { | ||
"codemirror": "file:" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
{ | ||
"name": "dijit", | ||
"version":"1.10.4", | ||
"version": "1.10.4", | ||
"directories": { | ||
"lib": "." | ||
}, | ||
"main":"main", | ||
"main": "main", | ||
"dependencies": { | ||
"dojo":"1.10.4" | ||
"dijit": "file:", | ||
"dojo": "1.10.4" | ||
}, | ||
"description": "Dijit provides a complete collection of user interface controls based on Dojo, giving you the power to create web applications that are highly optimized for usability, performance, internationalization, accessibility, but above all deliver an incredible user experience.", | ||
"licenses": [ | ||
{ | ||
"type": "AFLv2.1", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43" | ||
}, | ||
{ | ||
"type": "BSD", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13" | ||
} | ||
{ | ||
"type": "AFLv2.1", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43" | ||
}, | ||
{ | ||
"type": "BSD", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13" | ||
} | ||
], | ||
"bugs": "http://bugs.dojotoolkit.org/", | ||
"keywords": ["JavaScript", "Dojo", "Widget"], | ||
"keywords": [ | ||
"JavaScript", | ||
"Dojo", | ||
"Widget" | ||
], | ||
"homepage": "http://dojotoolkit.org/", | ||
"dojoBuild": "dijit.profile.js" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
{ | ||
"name": "dojo", | ||
"version":"1.10.4", | ||
"version": "1.10.4", | ||
"directories": { | ||
"lib": "." | ||
}, | ||
"main": "main", | ||
"description": "Dojo core is a powerful, lightweight library that makes common tasks quicker and easier. Animate elements, manipulate the DOM, and query with easy CSS syntax, all without sacrificing performance.", | ||
"licenses": [ | ||
{ | ||
"type": "AFLv2.1", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43" | ||
}, | ||
{ | ||
"type": "BSD", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13" | ||
} | ||
{ | ||
"type": "AFLv2.1", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43" | ||
}, | ||
{ | ||
"type": "BSD", | ||
"url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13" | ||
} | ||
], | ||
"bugs": "http://bugs.dojotoolkit.org/", | ||
"keywords": ["JavaScript", "Dojo", "Toolkit"], | ||
"keywords": [ | ||
"JavaScript", | ||
"Dojo", | ||
"Toolkit" | ||
], | ||
"homepage": "http://dojotoolkit.org/", | ||
"dojoBuild": "dojo.profile.js" | ||
"dojoBuild": "dojo.profile.js", | ||
"dependencies": { | ||
"dojo": "file:" | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,32 +312,32 @@ function handleMouseUp(screenSpaceEventHandler, event) { | |
return; | ||
} | ||
|
||
if (screenSpaceEventHandler._buttonDown[MouseButton.LEFT]) { | ||
if (screenSpaceEventHandler._buttonDown[0]) { | ||
cancelMouseEvent( | ||
screenSpaceEventHandler, | ||
ScreenSpaceEventType.LEFT_UP, | ||
ScreenSpaceEventType.LEFT_CLICK, | ||
event, | ||
); | ||
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] = false; | ||
screenSpaceEventHandler._buttonDown[0] = false; | ||
} | ||
if (screenSpaceEventHandler._buttonDown[MouseButton.MIDDLE]) { | ||
if (screenSpaceEventHandler._buttonDown[1]) { | ||
cancelMouseEvent( | ||
screenSpaceEventHandler, | ||
ScreenSpaceEventType.MIDDLE_UP, | ||
ScreenSpaceEventType.MIDDLE_CLICK, | ||
event, | ||
); | ||
screenSpaceEventHandler._buttonDown[MouseButton.MIDDLE] = false; | ||
screenSpaceEventHandler._buttonDown[1] = false; | ||
} | ||
if (screenSpaceEventHandler._buttonDown[MouseButton.RIGHT]) { | ||
if (screenSpaceEventHandler._buttonDown[2]) { | ||
cancelMouseEvent( | ||
screenSpaceEventHandler, | ||
ScreenSpaceEventType.RIGHT_UP, | ||
ScreenSpaceEventType.RIGHT_CLICK, | ||
event, | ||
); | ||
screenSpaceEventHandler._buttonDown[MouseButton.RIGHT] = false; | ||
screenSpaceEventHandler._buttonDown[2] = false; | ||
} | ||
} | ||
|
||
|
@@ -375,9 +375,9 @@ function handleMouseMove(screenSpaceEventHandler, event) { | |
Cartesian2.clone(position, previousPosition); | ||
|
||
if ( | ||
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] || | ||
screenSpaceEventHandler._buttonDown[MouseButton.MIDDLE] || | ||
screenSpaceEventHandler._buttonDown[MouseButton.RIGHT] | ||
screenSpaceEventHandler._buttonDown[0] || | ||
screenSpaceEventHandler._buttonDown[1] || | ||
screenSpaceEventHandler._buttonDown[2] | ||
) { | ||
event.preventDefault(); | ||
} | ||
|
@@ -541,12 +541,9 @@ function fireTouchEvents(screenSpaceEventHandler, event) { | |
let clickAction; | ||
const pinching = screenSpaceEventHandler._isPinching; | ||
|
||
if ( | ||
numberOfTouches !== 1 && | ||
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] | ||
) { | ||
if (numberOfTouches !== 1 && screenSpaceEventHandler._buttonDown[0]) { | ||
// transitioning from single touch, trigger UP and might trigger CLICK | ||
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] = false; | ||
screenSpaceEventHandler._buttonDown[0] = false; | ||
|
||
if (defined(screenSpaceEventHandler._touchHoldTimer)) { | ||
clearTimeout(screenSpaceEventHandler._touchHoldTimer); | ||
|
@@ -624,7 +621,7 @@ function fireTouchEvents(screenSpaceEventHandler, event) { | |
screenSpaceEventHandler._primaryPreviousPosition, | ||
); | ||
|
||
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] = true; | ||
screenSpaceEventHandler._buttonDown[0] = true; | ||
|
||
action = screenSpaceEventHandler.getInputAction( | ||
ScreenSpaceEventType.LEFT_DOWN, | ||
|
@@ -750,10 +747,7 @@ function fireTouchMoveEvents(screenSpaceEventHandler, event) { | |
const numberOfTouches = positions.length; | ||
let action; | ||
|
||
if ( | ||
numberOfTouches === 1 && | ||
screenSpaceEventHandler._buttonDown[MouseButton.LEFT] | ||
) { | ||
if (numberOfTouches === 1 && screenSpaceEventHandler._buttonDown[0]) { | ||
// moving single touch | ||
const position = positions.values[0]; | ||
Cartesian2.clone(position, screenSpaceEventHandler._primaryPosition); | ||
|
@@ -981,9 +975,9 @@ function handlePointerMove(screenSpaceEventHandler, event) { | |
function ScreenSpaceEventHandler(element) { | ||
this._inputEvents = {}; | ||
this._buttonDown = { | ||
LEFT: false, | ||
MIDDLE: false, | ||
RIGHT: false, | ||
0: false, // LEFT | ||
1: false, // MIDDLE | ||
2: false, // RIGHT | ||
}; | ||
Comment on lines
977
to
981
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this initialization should still rely on the values from this._buttonDown = {
[MouseButton.LEFT]: false,
[MouseButton.MIDDLE]: false,
[MouseButton.RIGHT]: false,
} |
||
this._isPinching = false; | ||
this._isTouchHolding = false; | ||
|
@@ -1137,4 +1131,4 @@ ScreenSpaceEventHandler.mouseEmulationIgnoreMilliseconds = 800; | |
* @default 1500 | ||
*/ | ||
ScreenSpaceEventHandler.touchHoldDelayMilliseconds = 1500; | ||
export default ScreenSpaceEventHandler; | ||
export default ScreenSpaceEventHandler; |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is functionally equivalent but harder to read. If you check the initialization of
MouseButton
on line 45 you can see the values are already integers. We should use that enum/constants everywhere else for readability. Please undo the changes like this one.