Mercurial > hg > mgallery
changeset 109:c8cfc6cc161a
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.)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 30 Oct 2016 15:22:03 +0200 |
parents | 417cdd9f8864 |
children | a987c8081891 |
files | mgallery.php |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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; <? echo