Handle width=100% and remove code that worked around montage layouts with width=%.

pull/3576/head
Isaac Connor 2022-08-15 13:01:49 -04:00
parent 82ff0c1082
commit de5b8bd893
1 changed files with 12 additions and 4 deletions

View File

@ -114,7 +114,13 @@ function MonitorStream(monitorData) {
} }
} else if (parseInt(width) || parseInt(height)) { } else if (parseInt(width) || parseInt(height)) {
if (width) { if (width) {
newscale = parseInt(100*parseInt(width)/this.width); if (width.search('px') != -1) {
newscale = parseInt(100*parseInt(width)/this.width);
} else { // %
// Set it, then get the calculated width
monitor_frame.css('width', width);
newscale = parseInt(100*parseInt(monitor_frame.width())/this.width);
}
} else if (height) { } else if (height) {
newscale = parseInt(100*parseInt(height)/this.height); newscale = parseInt(100*parseInt(height)/this.height);
width = parseInt(this.width * newscale / 100)+'px'; width = parseInt(this.width * newscale / 100)+'px';
@ -124,10 +130,11 @@ function MonitorStream(monitorData) {
width = Math.round(parseInt(this.width) * newscale / 100)+'px'; width = Math.round(parseInt(this.width) * newscale / 100)+'px';
height = Math.round(parseInt(this.height) * newscale / 100)+'px'; height = Math.round(parseInt(this.height) * newscale / 100)+'px';
} }
if (width && (width != '0px') && if (width && (width != '0px')
((monitor_frame[0].style.width===undefined) || (-1 == monitor_frame[0].style.width.search('%'))) // This next is for montage layouts where we use things like 33%
//&& ((monitor_frame[0].style.width===undefined) || (-1 == monitor_frame[0].style.width.search('%')))
) { ) {
monitor_frame.css('width', width); monitor_frame.css('width', parseInt(width));
} }
if (height && height != '0px') img.style.height = height; if (height && height != '0px') img.style.height = height;
@ -143,6 +150,7 @@ function MonitorStream(monitorData) {
const stream_frame = $j('#monitor'+this.id); const stream_frame = $j('#monitor'+this.id);
if (!newscale) { if (!newscale) {
newscale = parseInt(100*parseInt(stream_frame.width())/this.width); newscale = parseInt(100*parseInt(stream_frame.width())/this.width);
console.log("Calculated stream scale from ", stream_frame.width(), '/', this.width, '=', newscale);
} }
if (img.nodeName == 'IMG') { if (img.nodeName == 'IMG') {
if (newscale > 100) newscale = 100; // we never request a larger image, as it just wastes bandwidth if (newscale > 100) newscale = 100; // we never request a larger image, as it just wastes bandwidth