Skip to content

Commit 7371537

Browse files
authored
Fix to avoid objects to move when the gizmo dragging point is clicked (#8334)
1 parent 1d1c11b commit 7371537

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

GDJS/Runtime/InAppTutorialMessage.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ namespace gdjs {
148148
const topOrMiddleOrBottom = position.toLowerCase().includes('top')
149149
? 'top'
150150
: position.toLowerCase().includes('middle')
151-
? 'middle'
152-
: 'bottom';
151+
? 'middle'
152+
: 'bottom';
153153

154154
const containerPositionStyle: AbsolutePositionStyle = {};
155155
const messageContainerPositionStyle: AbsolutePositionStyle = {};
@@ -200,10 +200,8 @@ namespace gdjs {
200200
const messageContent = document.createElement('div');
201201
messageContent.innerHTML = nmd(message);
202202

203-
const {
204-
containerPositionStyle,
205-
messageContainerPositionStyle,
206-
} = _getPositioningStyle(position);
203+
const { containerPositionStyle, messageContainerPositionStyle } =
204+
_getPositioningStyle(position);
207205

208206
_loadFonts();
209207
_loadStyleSheet();

GDJS/Runtime/InGameEditor/InGameEditor.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,9 @@ namespace gdjs {
624624
}
625625

626626
class ObjectMover {
627-
editor: InGameEditor;
628-
_changeHappened = false;
627+
private editor: InGameEditor;
628+
private _changeHappened = false;
629+
private startTime = 0;
629630

630631
constructor(editor: InGameEditor) {
631632
this.editor = editor;
@@ -649,6 +650,7 @@ namespace gdjs {
649650
startMove() {
650651
this._changeHappened = false;
651652
this._objectInitialPositions.clear();
653+
this.startTime = Date.now();
652654
}
653655

654656
endMove(): boolean {
@@ -672,6 +674,10 @@ namespace gdjs {
672674
scaleZ: float;
673675
}
674676
) {
677+
if (Date.now() - this.startTime < 200) {
678+
// Avoid miss-clicks gizmo dragging point to change object positions.
679+
return;
680+
}
675681
selectedObjects.forEach((object) => {
676682
if (this.editor.isInstanceLocked(object)) {
677683
return;
@@ -2419,8 +2425,11 @@ namespace gdjs {
24192425
// Update the rotation snap.
24202426
const inputManager = this._runtimeGame.getInputManager();
24212427
const shouldSnap =
2422-
this._transformControlsMode === 'rotate' && isAltPressed(inputManager);
2423-
const rotationSnap = shouldSnap ? gdjs.toRad(ROTATION_SNAP_DEGREES) : null;
2428+
this._transformControlsMode === 'rotate' &&
2429+
isAltPressed(inputManager);
2430+
const rotationSnap = shouldSnap
2431+
? gdjs.toRad(ROTATION_SNAP_DEGREES)
2432+
: null;
24242433

24252434
threeTransformControls.setRotationSnap(rotationSnap);
24262435

GDJS/Runtime/debugger-client/InGameDebugger.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ namespace gdjs {
115115
}
116116

117117
if (this._uncaughtException) {
118-
const errorIsInJs = gdjs.AbstractDebuggerClient.isErrorComingFromJavaScriptCode(
119-
this._uncaughtException
120-
);
118+
const errorIsInJs =
119+
gdjs.AbstractDebuggerClient.isErrorComingFromJavaScriptCode(
120+
this._uncaughtException
121+
);
121122
this._uncaughtExceptionElement = (
122123
<div style={styles.errorContainer}>
123124
<button

GDJS/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"check-types": "tsc",
3030
"build": "node scripts/build.js",
3131
"test": "cd tests && npm run test-benchmark",
32-
"format": "prettier --write \"Runtime/**/*.ts\" \"../Extensions/**/*.ts\" \"../Extensions/**/JsExtension.js\" \"../Extensions/**/*.spec.js\"",
33-
"check-format": "prettier --list-different \"Runtime/**/*.ts\" \"../Extensions/**/*.ts\" \"../Extensions/**/JsExtension.js\" \"../Extensions/**/*.spec.js\"",
32+
"format": "prettier --write \"Runtime/**/*.ts\" \"Runtime/**/*.tsx\" \"../Extensions/**/*.ts\" \"../Extensions/**/JsExtension.js\" \"../Extensions/**/*.spec.js\"",
33+
"check-format": "prettier --list-different \"Runtime/**/*.ts\" \"Runtime/**/*.tsx\" \"../Extensions/**/*.ts\" \"../Extensions/**/JsExtension.js\" \"../Extensions/**/*.spec.js\"",
3434
"generate-doc": "typedoc --options docs/typedoc.json --plugin typedoc-plugin-reference-excluder"
3535
}
3636
}

0 commit comments

Comments
 (0)