jaridmargolin / bouncefix.js

🚫 Stop full body elastic scroll bounce when scrolling inside nested containers (IOS)
http://jaridmargolin.github.io/bouncefix.js/
84 stars 15 forks source link

bouncefix will make fastclick.js disable #7

Open YongX opened 9 years ago

YongX commented 9 years ago

Hello, I'm using fastclick.js together with bouncefix.js, they both work well for me, except when I reach the top or the bottom of my web, it looks like bouncefix.js will make a little scroll(1px), and that will make fastclick not work. Any suggestion?

burnedikt commented 9 years ago

There is a fix for this problem, though it's a bit hacky: https://github.com/ftlabs/fastclick/pull/357

dondevi commented 9 years ago

@YongX Here is a Hack you can try:

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