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
Labels

Comments

@dev-rke
Copy link

@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
Copy link
Owner

@NeXTs 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 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 ghost commented Oct 13, 2015

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

@Abhinav1217
Copy link

@Abhinav1217 Abhinav1217 commented Oct 16, 2015

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

@NeXTs 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

@Abhinav1217 Abhinav1217 commented Nov 12, 2015

Will try this today. Thanks.

@dev-rke
Copy link
Author

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.