My site renders on any size screen, mobile or desktop, however, if the user changes the orientation (or resizes the browser window on desktop), my site needs to reload/re-render the page - its basically a gallery page of preview images, set with certain spacing between the images. The problem is that on mobile browsers the resize event fires whenever the user scrolls up/down, because of the URL bar autohiding function.
I have some Javascript that takes care of most cases, just that the edge case of a user resizing the browser window vertically only on desktop wont fire, because the script will only check changes in width.
var resizeTimeout;
var wow = window.outerWidth;
window.addEventListener('resize',
function(event) {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(
function(){
if (window.outerWidth !== wow) {
window.location.reload(true);
wow = window.outerWidth;
}
}, 500
);
}
);
Ive read the posts, related to browser detection strings, feature detection, and Modernizr. For some reason hover mq and pointer mq dont seem to be working for me in terms of media queries in Javascript.
Is there any way to detect if a browser is using those annoying autohide URL bars? It will help me to find the case where the user is vertically resizing the browser window on desktop. I dont want to disable the the url bar. But fixing it permanently so it cant autohide is the option Im considering. Any ideas?