iphone/ipad triggering unexpected resize events

前端 未结 8 2079
北荒
北荒 2020-12-13 01:54

I\'m working on a mobile version of my site. I\'m using media queries and CSS as much as possible, but I\'m also using some javascript to, for example, turn my navigation in

8条回答
  •  心在旅途
    2020-12-13 01:59

    I found out the answer in StackOverflow itself link of the solution. it's the answer by sidonaldson that helped me solve an issue faced earlier like this. ty

    the answer is:

    var cachedWidth = $(window).width();
        $(window).resize(function(){
            var newWidth = $(window).width();
            if(newWidth !== cachedWidth){
                //DO RESIZE HERE
                cachedWidth = newWidth;
            }
        });
    

提交回复
热议问题