diff --git a/js/activity.js b/js/activity.js index 682d24f670..4c161ff194 100644 --- a/js/activity.js +++ b/js/activity.js @@ -1756,25 +1756,17 @@ class Activity { */ this._setupBlocksContainerEvents = () => { const moving = false; - let lastCoords = { - x: 0, - y: 0, - delta: 0 - }; - const that = this; + let lastCoords = { x: 0, y: 0, delta: 0 }; /** * Closes any open menus and labels. */ const closeAnyOpenMenusAndLabels = () => { - if (docById("wheelDiv") !== null) docById("wheelDiv").style.display = "none"; - if (docById("contextWheelDiv") !== null) - docById("contextWheelDiv").style.display = "none"; - if (docById("helpfulWheelDiv") !== null) - docById("helpfulWheelDiv").style.display = "none"; - if (docById("textLabel") !== null) docById("textLabel").style.display = "none"; - if (docById("numberLabel") !== null) docById("numberLabel").style.display = "none"; + ['wheelDiv', 'contextWheelDiv', 'helpfulWheelDiv', 'textLabel', 'numberLabel'].forEach(id => { + const elem = docById(id); + if (elem) elem.style.display = 'none'; + }); }; /** @@ -1898,30 +1890,23 @@ class Activity { * @param {WheelEvent} event - The wheel event object. */ const __wheelHandler = (event) => { - const data = normalizeWheel(event); // normalize over different browsers + const data = normalizeWheel(event); const delY = data.pixelY; const delX = data.pixelX; - - //Ctrl+MouseWheel Zoom functionality + if (event.ctrlKey) { - event.preventDefault(); // Prevent default scrolling behavior - - if (delY < 0 && doLargerBlocks(this));//Zoom IN - if (delY >= 0 && doSmallerBlocks(this));//Zoom Out - } - if (delY !== 0 && event.axis === event.VERTICAL_AXIS) { - closeAnyOpenMenusAndLabels(); // closes all wheelnavs when scrolling . + event.preventDefault(); + delY < 0 ? doLargerBlocks(that) : doSmallerBlocks(that); + } else if (delY !== 0 && event.axis === event.VERTICAL_AXIS) { + closeAnyOpenMenusAndLabels(); that.blocksContainer.y -= delY; - } - // horizontal scroll - if (that.scrollBlockContainer) { - if (delX !== 0 && event.axis === event.HORIZONTAL_AXIS) { - closeAnyOpenMenusAndLabels(); - that.blocksContainer.x -= delX; - } + } else if (that.scrollBlockContainer && delX !== 0 && event.axis === event.HORIZONTAL_AXIS) { + closeAnyOpenMenusAndLabels(); + that.blocksContainer.x -= delX; } else { event.preventDefault(); } + that.refreshCanvas(); }; @@ -1973,12 +1958,10 @@ class Activity { that.stage.removeAllEventListeners("stagemousemove"); that.stage.on("stagemousemove", (event) => { - that.stageX = event.stageX; - that.stageY = event.stageY; - - if (!moving) { - return; - } + that.stageX = moveEvent.stageX; + that.stageY = moveEvent.stageY; + + if (!that.moving) return; // if we are moving the block container, deselect the active block. // Deselect active block if moving the block container @@ -4182,7 +4165,7 @@ class Activity { let st = sched[j].start; let ed= sched[j].end; let dur = ed - st; - var temp = this.getClosestStandardNoteValue(dur * 3 / 8); + let temp = this.getClosestStandardNoteValue(dur * 3 / 8); shortestNoteDenominator=Math.max(shortestNoteDenominator,temp[1]); } @@ -4224,7 +4207,7 @@ class Activity { } return ar; }; - var obj = this.getClosestStandardNoteValue(duration * 3 / 8); + let obj = this.getClosestStandardNoteValue(duration * 3 / 8); // let scalingFactor=1; // if(shortestNoteDenominator>32) // scalingFactor=shortestNoteDenominator/32;