Pagination on scroll end for REST services #44

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

Projects

None yet

3 participants

@dev-rke
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 NeXTs added the enhancement label Aug 25, 2015
@NeXTs
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
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
ghost commented Oct 13, 2015

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

@Abhinav1217

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 in 2878963 Nov 11, 2015
@NeXTs
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

Will try this today. Thanks.

@dev-rke
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