Skip to content

Commit 2072f2b

Browse files
Merge pull request #19 from MakingSpiderSense/revert-18-bugfix/movement-speed-modifier/118-show-speed-lines-on-mobile
Revert "Add touch event listeners for mobile movement tracking in speed modifier component"
2 parents 75fe95c + 067b780 commit 2072f2b

1 file changed

Lines changed: 1 addition & 53 deletions

File tree

src/components/movement-speed-modifier/movement-speed-modifier.js

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,17 @@ const movementSpeedModifierComponent = {
3232
this.currentAppliedMultiplier = 1; // Set to 1 initially as the boost needs to be triggered
3333
this.axisX = 0;
3434
this.axisY = 0;
35-
this.touchCount = 0;
3635
this.timeSinceLastLinePattern = 0;
3736
// Bind handlers to this component instance, and store the references so listeners can be removed later
3837
this.onThumbstickDown = this.onThumbstickDown.bind(this);
3938
this.onAxisMove = this.onAxisMove.bind(this);
4039
this.onKeyDown = this.onKeyDown.bind(this);
4140
this.onKeyUp = this.onKeyUp.bind(this);
4241
this.onWindowBlur = this.onWindowBlur.bind(this);
43-
this.onTouchStart = this.onTouchStart.bind(this);
44-
this.onTouchEnd = this.onTouchEnd.bind(this);
4542
// Set up input listeners
4643
this.leftControllerEl = this.data.leftController;
4744
this.addLeftControllerListeners();
4845
this.addKeyboardListeners();
49-
this.addTouchListeners();
5046
// Create the speed line container and line elements
5147
this.lineContainer = null;
5248
this.lineElements = [];
@@ -101,7 +97,6 @@ const movementSpeedModifierComponent = {
10197
remove: function () {
10298
this.removeLeftControllerListeners();
10399
this.removeKeyboardListeners();
104-
this.removeTouchListeners();
105100
this.resetSpeeds();
106101
this.removeSpeedLines();
107102
},
@@ -150,28 +145,6 @@ const movementSpeedModifierComponent = {
150145
window.removeEventListener("blur", this.onWindowBlur);
151146
},
152147

153-
/**
154-
* Add touch listeners
155-
*
156-
* Adds touch listeners to track the number of fingers on the screen for mobile movement.
157-
*/
158-
addTouchListeners: function () {
159-
window.addEventListener("touchstart", this.onTouchStart);
160-
window.addEventListener("touchend", this.onTouchEnd);
161-
window.addEventListener("touchcancel", this.onTouchEnd);
162-
},
163-
164-
/**
165-
* Remove touch listeners
166-
*
167-
* Removes the touch listeners used for mobile movement tracking.
168-
*/
169-
removeTouchListeners: function () {
170-
window.removeEventListener("touchstart", this.onTouchStart);
171-
window.removeEventListener("touchend", this.onTouchEnd);
172-
window.removeEventListener("touchcancel", this.onTouchEnd);
173-
},
174-
175148
/**
176149
* Thumbstick down handler
177150
*
@@ -260,30 +233,6 @@ const movementSpeedModifierComponent = {
260233
this.applySpeedMultiplier();
261234
},
262235

263-
/**
264-
* Touch start handler
265-
*
266-
* Tracks the number of fingers on the screen to detect forward or backward movement on mobile.
267-
*
268-
* @param {TouchEvent} event The touch event.
269-
*/
270-
onTouchStart: function (event) {
271-
this.touchCount = event.touches.length;
272-
this.syncSpeedLinesVisibility();
273-
},
274-
275-
/**
276-
* Touch end handler
277-
*
278-
* Tracks the number of fingers on the screen to detect when movement stops on mobile.
279-
*
280-
* @param {TouchEvent} event The touch event.
281-
*/
282-
onTouchEnd: function (event) {
283-
this.touchCount = event.touches.length;
284-
this.syncSpeedLinesVisibility();
285-
},
286-
287236
/**
288237
* Is joystick forward
289238
*
@@ -338,8 +287,7 @@ const movementSpeedModifierComponent = {
338287
const keyboardMovingForward = this.keyboardForwardActive;
339288
const joystickMovingForward = this.isJoystickForward();
340289
const armSwingMovingForward = armSwingMovement && armSwingMovement.moving && !armSwingMovement.reverseHeld;
341-
const touchMovingForward = this.touchCount === 1; // 1 finger = forward, 2 = backward
342-
return keyboardMovingForward || joystickMovingForward || armSwingMovingForward || touchMovingForward;
290+
return keyboardMovingForward || joystickMovingForward || armSwingMovingForward;
343291
},
344292

345293
/**

0 commit comments

Comments
 (0)