Skip to content

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/check-for-CLA/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"main": "index.js",
"dependencies": {
"@cesium/check-for-cla": "file:",
"@octokit/core": "^6.1.2",
"fs-extra": "^11.2.0",
"googleapis": "^137.1.0",
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Andrew Dassonville](https://github.com/andrewda)
- [Cody Butler](https://github.com/CodyBu)
- [Hiwen](https://github.com/Hiwen)
- [Ayush Das](https://github.com/ayushd150)
3 changes: 3 additions & 0 deletions ThirdParty/codemirror-5.52.0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
"directories": {},
"dependencies": {},
"devDependencies": {}
},
"dependencies": {
"codemirror": "file:"
}
}
29 changes: 17 additions & 12 deletions ThirdParty/dojo-release-1.10.4/dijit/package.json
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"
}
29 changes: 18 additions & 11 deletions ThirdParty/dojo-release-1.10.4/dojo/package.json
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:"
}
}
1 change: 1 addition & 0 deletions Tools/rollup-plugin-strip-pragma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],
"dependencies": {
"magic-string": "^0.25.3",
"rollup-plugin-strip-pragma": "file:",
"rollup-pluginutils": "^2.8.2"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
],
"dependencies": {
"@cesium/engine": "^17.0.0",
"@cesium/widgets": "^12.0.0"
"@cesium/widgets": "^12.0.0",
"cesium": "file:"
},
"devDependencies": {
"@cesium/eslint-config": "^12.0.0",
Expand Down
40 changes: 17 additions & 23 deletions packages/engine/Source/Core/ScreenSpaceEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,32 +312,32 @@ function handleMouseUp(screenSpaceEventHandler, event) {
return;
}

if (screenSpaceEventHandler._buttonDown[MouseButton.LEFT]) {
if (screenSpaceEventHandler._buttonDown[0]) {
Copy link
Contributor

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.

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;
}
}

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this initialization should still rely on the values from MouseButton so they're consistent. You can set the properties dynamically using the enum constants.

this._buttonDown = {
  [MouseButton.LEFT]: false,
  [MouseButton.MIDDLE]: false,
  [MouseButton.RIGHT]: false,
}

this._isPinching = false;
this._isTouchHolding = false;
Expand Down Expand Up @@ -1137,4 +1131,4 @@ ScreenSpaceEventHandler.mouseEmulationIgnoreMilliseconds = 800;
* @default 1500
*/
ScreenSpaceEventHandler.touchHoldDelayMilliseconds = 1500;
export default ScreenSpaceEventHandler;
export default ScreenSpaceEventHandler;
1 change: 1 addition & 0 deletions packages/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"./Specs/**/*"
],
"dependencies": {
"@cesium/engine": "file:",
"@tweenjs/tween.js": "^25.0.0",
"@zip.js/zip.js": "^2.7.34",
"autolinker": "^4.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"@cesium/engine": "^17.0.0",
"@cesium/widgets": "file:",
"nosleep.js": "^0.12.0"
},
"type": "module",
Expand Down