django-el-pagination
django-el-pagination copied to clipboard
Need an ability to attach scroll event to some DIV, not only $(document)
Hi,
We use two el-pagination on the same page to have endless scrolling (twitter style) on left bar (list of some items) and right bar (list of some other items).
Unfortunately, it seems el-pagination currently supports only $(document) scrolling events.
May we have something like $(settings.scrollContainer).on('scroll', function () {
instead of doc.on('scroll', function () {
here?
See tests project example https://github.com/shtalinberg/django-el-pagination/blob/develop/tests/project/templates/chunks/index.html just remove chunk functionality
On the chunks test page, you scroll $(document).
In my case, "Object" and "Item" lists could be scrolled independently (each has it's own height: 100vh; overflow-y: auto;
). Which breaks el-pagination.js functionality.
I have it quick-and-dirty fixed by the following:
if (settings.paginateOnScroll) {
var win = $(settings.scrollContainer || window),
doc = $(settings.scrollContainer || document);
doc.on('scroll', function () {
let docHeight = (settings.scrollContainer) ? doc[0].scrollHeight : doc.height();
let scrollMargin = docHeight - win.height() - win.scrollTop();
if (scrollMargin <= settings.paginateOnScrollMargin) {
Would be wonderful to see a proper fix in upstream.