# HG changeset patch # User Matti Hamalainen # Date 1477833723 -7200 # Node ID c8cfc6cc161a91477689f94d000dd854b6d7f7b1 # Parent 417cdd9f8864a5fb76bec903a1910027ca6aabce Adjust image scaling to be delayed and not being done on each resize event (for example Firefox fullscreen switching animates by default and triggers LOTS of resize events, which makes things slow.) diff -r 417cdd9f8864 -r c8cfc6cc161a mgallery.php --- a/mgallery.php Sat Oct 29 20:28:52 2016 +0300 +++ b/mgallery.php Sun Oct 30 15:22:03 2016 +0200 @@ -704,11 +704,11 @@ } -function mgalAdjustImage() +function mgalAdjustImageDo() { var eimg = document.getElementById("imageImage"); var win = mgalGetWindowSize(); - var madj = 0.80; + var madj = 0.81; if (eimg) { if (eimg.width > eimg.height) @@ -730,12 +730,21 @@ eimg.style.height = "100%"; } } + adjustPID = -1; } -mgalAddEvent(document.getElementById("imageImage"), "load", mgalAdjustImage); +function mgalAdjustImage() +{ + if (adjustPID == -1) + adjustPID = setTimeout(mgalAdjustImageDo, 500); +} + + +mgalAddEvent(document.getElementById("imageImage"), "load", mgalAdjustImageDo); mgalAddEvent(window, "resize", mgalAdjustImage); mgalAddEvent(document, "keypress", mgalProcessKeyPress); +adjustPID = -1;