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

Pagination on scroll end for REST services #44

Closed
dev-rke opened this issue Aug 23, 2015 · 7 comments
Closed

Pagination on scroll end for REST services #44

dev-rke opened this issue Aug 23, 2015 · 7 comments

Comments

@dev-rke
Copy link

dev-rke commented Aug 23, 2015

I just thought about if it might be possible to define an event before further
data will be appended e.g. using ajax like for paginated data.

E.g. you load page one from a REST service and want to load additional pages when the user scrolls down to the end and before he reaches the end further data will be loaded.

Pseudocode:

// user defined setting
options.percentageScrollOffsetBeforeLoadData = 0.95;

// clusterize
if(options.loadDataCallback()) {
  $elementWithScrollbar.on('scroll',function(e) {
    percentageScrollOffset = $(this).scrollTop / totalheight;
    if(percentageScrollOffset > options.percentageScrollOffsetBeforeLoadData) {
      options.loadDataCallback()
    }
  });
}

This would enable the user to handle additional page loads without manually
injecting in the event handling of clusterize.

@NeXTs
Copy link
Owner

NeXTs commented Aug 25, 2015

Hi, this is good idea.
In the nearest future I will implement list of callbacks and events for most useful needs. Probably I'll consider this case too.

Questions to developers: do you need this feature? Should I increase the plugin's size by this functionality ?

@dev-rke
Copy link
Author

dev-rke commented Aug 25, 2015

If you want to keep it small, it might also be a good alternative just to expose some hooks where one can enhance the functionality with a custom implementation.

Another alternative might be to split the functionality in two modules: a very small core module and an extended feature module, which hooks into the core.

@ghost
Copy link

ghost commented Oct 13, 2015

Yep, it's worth of it. Hope will be impelmented

@Abhinav1217
Copy link

I would like to not increase the size of the plugin for this feature. But to expose some callback hooks which can be used to extend core plugin with all the extra functionalities including this.

@NeXTs NeXTs closed this as completed in 2878963 Nov 11, 2015
@NeXTs
Copy link
Owner

NeXTs commented Nov 11, 2015

Now you able to subscribe to update scroll position via scrollingProgress callback. Or get progress position directly via calling getScrollProgress method.

var clusterize = new Clusterize({
  rows: data,
  scrollId: 'scrollArea',
  contentId: 'contentArea',
  callbacks: {
    scrollingProgress: function(progress) {
      if( progress > 80 ) {
        // do stuff
      }
    }
  }
});

// or call it directly
console.log(clusterize.getScrollProgress());

@Abhinav1217
Copy link

Will try this today. Thanks.

@dev-rke
Copy link
Author

dev-rke commented Nov 12, 2015

Great! Thank you! :-)

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

No branches or pull requests

3 participants