Destructuring: Instead of accessing e.deltaY multiple times, we can destructure it directly in the function parameters. This makes the code cleaner and easier to read.
Early Return: Instead of wrapping the adjustBrushSize call in an if statement, we can return early if the condition is not met. This reduces the level of indentation and makes the code more readable. Implicit Return: In arrow functions, if the function body consists of a single statement, you can omit the braces and the return keyword. This makes the code more concise. However, in this case, we need to explicitly return false to prevent the default action.testing_refactoring
parent
37d49a66b4
commit
4330e06ebe
|
|
@ -1175,20 +1175,19 @@ onUiLoaded(async () => {
|
|||
});
|
||||
|
||||
/**
|
||||
* Event listener for wheel event on the target element to handle zoom and brush size adjustment.
|
||||
*/
|
||||
targetElement.addEventListener("wheel", (e) => {
|
||||
* Event listener for wheel event on the target element to handle zoom and brush size adjustment.
|
||||
*/
|
||||
targetElement.addEventListener("wheel", ({ deltaY }) => {
|
||||
const isDefaultCanvas = checkIsDefault(elementIDs, elemId);
|
||||
|
||||
if (!isDefaultCanvas || !window.applyZoomAndPan) {
|
||||
const operation = e.deltaY > 0 ? "-" : "+";
|
||||
changeZoomLevel(operation, e);
|
||||
changeZoomLevel(deltaY > 0 ? "-" : "+", deltaY);
|
||||
}
|
||||
|
||||
if (!isModifierKey(e, hotkeysConfig.canvas_hotkey_adjust)) return;
|
||||
if (!isModifierKey(deltaY, hotkeysConfig.canvas_hotkey_adjust)) return;
|
||||
|
||||
e.preventDefault();
|
||||
adjustBrushSize(elemId, e.deltaY, false, hotkeysConfig.canvas_zoom_brush_size_change);
|
||||
adjustBrushSize(elemId, deltaY, false, hotkeysConfig.canvas_zoom_brush_size_change);
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue