From 71a08c94dd5da4ef51403ab584c00a5124bd2255 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Sat, 1 Jun 2024 23:32:53 +0300 Subject: [PATCH] Fix: For bind/unbind events use namespaced (panzoom.js) - When disable, also perform unbind keyup, keydown - Code optimization. --- web/js/panzoom.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/web/js/panzoom.js b/web/js/panzoom.js index 407c41088..19b689345 100644 --- a/web/js/panzoom.js +++ b/web/js/panzoom.js @@ -15,15 +15,9 @@ var zmPanZoom = { const _this = this; $j('.zoompan').each( function() { _this.action('enable', {obj: this}); - var id; - if (this.querySelector("[id^='liveStream']")) { - //Montage & Watch page - id = stringToNumber(this.querySelector("[id^='liveStream']").id); - } else { - //Event page - id = eventData.MonitorId; - } - $j(document).on('keyup keydown', function(e) { + const stream = this.querySelector("[id^='liveStream']"); + const id = (stream) ? stringToNumber(stream.id) /* Montage & Watch page */ : eventData.MonitorId /* Event page */; + $j(document).on('keyup.panzoom keydown.panzoom', function(e) { _this.shifted = e.shiftKey ? e.shiftKey : e.shift; _this.ctrled = e.ctrlKey; _this.manageCursor(id); @@ -69,6 +63,7 @@ var zmPanZoom = { _this.setTriggerChangedMonitors(id); }); } else if (action == "disable") { //Disable a specific object + $j(document).off('keyup.panzoom keydown.panzoom'); $j('.btn-zoom-in').addClass('hidden'); $j('.btn-zoom-out').addClass('hidden'); this.panZoom[param['id']].reset();