When I view my site in Chrome mobile, the jQuery resize event gets triggered on scroll. As far as I can tell, it’s the change in height when scrolling that’s triggering it. My event should only be triggered when the width changes, not height…
$(window).resize(function() {
if ($(window).width() < 688) {
$('nav ul').css('display', 'none');
$('nav p').removeClass('active');
}
else {
$('nav ul').css('display', 'inherit');
}
});
The only related answer I could find to this is mobile chrome fires resize event on scroll.
onOrientationChange is mentioned, but that’s not what I need as it's not based on device orientation, but rather any width under 688px width.
Another mention is:
var width = $(window).width(), height = $(window).height();
then in your resize event handler you can do.
if($(window).width() != width && $(window).height() != height){
//Do something
}
Which looks like something I need, but I don’t understand jQuery well enough to know how to change that to work with what I need it to do.
Any ideas?