Fix bug wrong code trigger on resize

On some devices like iOS, the resize event is triggered not only by rotating but also by swipe actions!!!

In this case, you can use this script to solve the problem. It bases on the basic snippet of code that handles when the window is resized plus a special case (on swipe).


// Window Resize
var width = $(window).width();
var resize = 0;
$(window).resize(function() {
    var _self = $(this);
    setTimeout(function() {
        if (resize === 0) {
            // Done resize ...
           if (_self.width() !== width) {
               width = _self.width();
               // Done resize width ...
    }, 200);

Leave a Reply