Skip to content

Fix scrollend event not being fired in some cases#270

Open
jabberfest wants to merge 3 commits intojamesflorentino:masterfrom
jabberfest:bug/scrollend-not-firing
Open

Fix scrollend event not being fired in some cases#270
jabberfest wants to merge 3 commits intojamesflorentino:masterfrom
jabberfest:bug/scrollend-not-firing

Conversation

@jabberfest
Copy link
Copy Markdown

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

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

@jabberfest
Copy link
Copy Markdown
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
Copy Markdown
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