bouncefix.js icon indicating copy to clipboard operation
bouncefix.js copied to clipboard

FYI scrolling manipulation on click

Open jensstalder opened this issue 11 years ago • 0 comments

When I have anchors in a scrollable div, tapping on it causes the div do scroll down 1px if its on top. This causes iOS to register a change after tap and initializes a pause until re-tap. This is a behavior of iOS to allow drop downs and the like to function.

utils.scrollToEnd = function (el) {
    var curPos = el.scrollTop, height = el.offsetHeight, scroll = el.scrollHeight;
    // If at top, bump down 1px
    if (curPos <= 0) {
      el.scrollTop = 1; // <<<<< HERE
    }
    // If at bottom, bump up 1px
    if (curPos + height >= scroll) {
      el.scrollTop = scroll - height - 1;
    }
  };

jensstalder avatar Jun 22 '14 08:06 jensstalder