Skip to content

Comments

fixes resize event stutter on iOS devices#8

Open
taberrr wants to merge 1 commit intojjenzz:masterfrom
taberrr:master
Open

fixes resize event stutter on iOS devices#8
taberrr wants to merge 1 commit intojjenzz:masterfrom
taberrr:master

Conversation

@taberrr
Copy link

@taberrr taberrr commented Jan 30, 2017

The window.onResize event was causing text stuttering/flickering when scrolling the page on iOS devices, so this PR ensures the window's width has actually changed before acting on the resize event.

return;
}
windowWidth = $(window).width();

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taberrr, thanks for this fix. It would be great if you could cache the window reference and add a comment explaining why this is required though please if you don't mind?

if (base.opts.responsive) {
  var $window = $(window);
  var windowWidth = $window.width();

  var resize = function() {
    // Scrolling on iOS6+ fires the resize event. This ensures the width has actually changed
    // before continuing. https://tinyurl.com/ios-scroll-resize
    if ($window.width() === windowWidth) {
      return;
    }
    
    windowWidth = $window.width();
    //etc.
  }

  $window.on('resize.' + namespace, resize);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants