resize handler: run only one loop and trigger the handler when zoom level changes

This commit is contained in:
jean-emmanuel 2016-12-12 13:09:34 +01:00
parent 9ef7a63520
commit 7cb7c806c3
2 changed files with 6 additions and 3 deletions

View file

@ -44,6 +44,7 @@ var scrolls = function(){
document.documentElement.style.setProperty("--pixel-scale",'')
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
$(window).resize()
}
})
$(document).on('keydown.resetzoom', function(e){
@ -51,6 +52,8 @@ var scrolls = function(){
PXSCALE = INITIALZOOM
document.documentElement.style.setProperty("--pixel-scale",'')
document.documentElement.style.setProperty("--pixel-scale",PXSCALE)
$(window).resize()
}
})

View file

@ -80,16 +80,16 @@
}
// Loop.
resizePollingLoop()
}
function resizePollingLoop() {
// yep, setTimeout, 'cuz requestAnimation doesn't seem to perform that well
resizeTimeout = window.setTimeout(checkResizes, pollInterval)
checkResizes()
resizeTimeout = window.setTimeout(resizePollingLoop, pollInterval)
}
$(window).resize(checkResizes)
resizePollingLoop()
})(jQuery)