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

_bindScroll in infinity-loader.js sets wrong scroll element #5

Closed
timohermans opened this issue Mar 25, 2015 · 4 comments
Closed

_bindScroll in infinity-loader.js sets wrong scroll element #5

timohermans opened this issue Mar 25, 2015 · 4 comments

Comments

@timohermans
Copy link

There is actually one issue and one suggestion :)

  1. when the page renders the infinity-loader component it assigns the guid to the ID. This makes the scrolling never trigger:

the html to support the ID assigning (how it's rendered):

<div id="ember479" class="ember-view infinity-loader">  <span>Loading Infinite Model...</span>
</div>

infinity-loader.js

Ember.$(window).on("scroll."+this.get('guid'), function() {

should be

//mind the space
Ember.$(window).on("scroll #"+this.get('guid'), function() { 
  1. I would like to suggest making a string property 'scrollElement' that is used to determine what scroll element is used, with a default to window. My application has the overflow on a different element than window.
Ember.$(window).on("scroll."+this.get('guid'), function() {

will be

Ember.$(scrollElement).on("scroll."+this.get('guid'), function() {
@hhff
Copy link
Collaborator

hhff commented Mar 25, 2015

Hi @temo44 !

Thanks for this! Check this link. It explains why we're using the infinity-loader's guid for the event namespace. It's standard jQuery practise to use . to namespace an event. Seeing as a developer will probably be binding other scroll events to the window, we want to be sure to only remove this particular one when the infinity-scroller is destroyed. Make sense?

Also - check out the latest release (just released this morning) #4 - it now has a "scrollable" attribute that can be used to pass in a selector string 😄

@timohermans
Copy link
Author

Thank you for the reply @hhff !

It makes total sense. However, won't the selector still be incorrect, as Ember generates infinity-loader's guid as an ID, and not a class?

Cool that the feature is introduced 😄.

Awesome addon btw!

@hhff
Copy link
Collaborator

hhff commented Mar 25, 2015

Thanks @temo44 !

The guid is only used as the event namespace - ie: the unique string that "scrollable" (usually the window) uses to identify the event name. It's not a selector - it's a scroll event with a unique namespace.

it could be

Ember.$(scrollElement).on("scroll."+Math.random(), function() {

But a GUID is guaranteed to be unique. make sense?

@timohermans
Copy link
Author

Aaah thanks! It totally makes sense now.

I know where my thought process went wrong 😄 ! I still thought it was part of the 'not-scrolling' problem(hence, the idea that it's a selector instead of a namespace), because I have a different scrolling element. Thank you so much!

@hhff hhff closed this as completed Mar 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants