Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrollend event not being fired in some cases #270

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jabberfest
Copy link

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
Copy link
Author

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
Copy link
Collaborator

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

@jabberfest
Copy link
Author

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
Copy link
Collaborator

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

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

Successfully merging this pull request may close these issues.

2 participants