jamesflorentino / nanoScrollerJS

A jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars.
http://jamesflorentino.github.com/nanoScrollerJS/
MIT License
2.69k stars 502 forks source link

Fix scrollend event not being fired in some cases #270

Open jabberfest opened 10 years ago

jabberfest commented 10 years ago

In certain cases the "scrollend" event is never fired. Chrome and Firefox rounds values down for scrollTop.

In some cases contentScrollTop is one less than maxScroll top despite being scrolled all the way down.

  if @contentScrollTop >= @maxScrollTop and @prevScrollTop isnt @maxScrollTop
            @$el.trigger 'scrollend'
jabberfest commented 10 years ago

See:

https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollHeight https://developer.mozilla.org/en-US/docs/Web/API/Element.clientHeight

The following will get you subpixel values for scrollHeight and clientHeight but it only works on IE9+. The solution I propose at least works with older browsers.

@jamesflorentino, @kristerkari any thoughts?

element.getBoundingClientRect() Element.getBoundingClientRect().

kristerkari commented 10 years ago

@jabberfest Thanks! I'll have to test this in different browsers to verify the fix.

jabberfest commented 10 years ago

I just realized that my approach breaks the scroll event that fires when the scroll bar is at the beginning. this is due to me just adding a 1 pixel offset

kristerkari commented 10 years ago

Oh yeah true, then we need to think about an alternative solution.