Skip to content

Commit

Permalink
You can't change size in a ResizeObserver. So do what we do in montag…
Browse files Browse the repository at this point in the history
…e, just add the affected element to an array and deal with it in an interval
  • Loading branch information
Isaac Connor committed Sep 25, 2024
1 parent 689881d commit c9aa03d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion web/skins/classic/views/js/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var filterQuery = '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms]
var idle = 0;
var monitorStream = false; /* Stream is not started */
var currentMonitor;
var changedMonitors = [];

var classSidebarL = 'col-sm-3'; /* id="sidebar" */
var classSidebarR = 'col-sm-2'; /* id="ptzControls" */
Expand Down Expand Up @@ -1063,8 +1064,12 @@ function initPage() {

// Creating a ResizeObserver Instance
observer = new ResizeObserver((objResizes) => {
// We can't do the actual resizing in the Observer, it causes a loop. Need to just set a flag and do it in an interval.
objResizes.forEach((obj) => {
monitorsSetScale(monitorId);
const id = stringToNumber(obj.target.id);
if (!changedMonitors.includes(id)) {
changedMonitors.push(id);
}
});
});

Expand All @@ -1073,6 +1078,16 @@ function initPage() {
observer.observe(this);
});

setInterval(() => { //Updating GridStack resizeToContent, Scale & Ratio
if (changedMonitors.length > 0) {
changedMonitors.slice().reverse().forEach(function(item, index, object) {
const img = document.getElementById('liveStream'+item);
changedMonitors.splice(object.length - 1 - index, 1);
monitorsSetScale(item);
});
}
}, 100);

// Event listener for double click
//var elStream = document.querySelectorAll('[id ^= "liveStream"], [id ^= "evtStream"]');
var elStream = document.querySelectorAll('[id = "wrapperMonitor"]');
Expand Down

0 comments on commit c9aa03d

Please sign in to comment.