You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains 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
Drag Threshold The drag detection logic uses a hard-coded threshold of 10 pixels. Consider making this a configurable parameter to allow easier adjustments based on different device resolutions or user preferences.
Event Listener Removal The 'mousemove' event listener is removed as soon as the drag condition is met. This could lead to issues if the user stops and then starts moving the mouse again within the same mousedown session. Consider handling this scenario more gracefully.
Add error handling for the checkDrag function to manage exceptions that may occur during the drag detection process, ensuring the application's robustness.
Why: Adding error handling to the checkDrag function increases the robustness of the application by managing potential exceptions during the drag detection process.
9
Maintainability
Replace hardcoded values with a constant for the drag threshold
Replace the hardcoded drag threshold value with a constant to improve maintainability and readability. This allows easy adjustments and ensures consistency across the codebase if used in multiple places.
Why: Using a constant for the drag threshold improves maintainability and readability, making it easier to adjust the value and ensuring consistency across the codebase.
8
Best practice
Ensure proper cleanup of event listeners
Ensure the removal of the "mousemove" event listener when the component is destroyed or when it is no longer needed to prevent potential memory leaks and performance issues.
window.addEventListener("mousemove", checkDrag);
+// Ensure to remove this event listener appropriately when not needed anymore
Suggestion importance[1-10]: 7
Why: Adding a comment to remind developers to remove the event listener helps prevent potential memory leaks and performance issues, although it would be better to implement the actual cleanup code.
7
Readability
Use a more descriptive type name for mouse event types
Consider using a more descriptive type name than ListenerTypes to reflect that it specifically relates to mouse events, enhancing code readability and maintainability.
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.
User description
Closes #1158
PR Type
Bug fix
Description
mouseup
event listener and added drag detection logic within thehandleMouseDown
method.isDragged
flag to track whether a drag operation has occurred.Changes walkthrough 📝
InputManager.ts
Fix click event firing after drag operation
client/src/three/components/InputManager.ts
mouseup
event listener.isDragged
flag to track drag state.handleMouseDown
.