django-el-pagination icon indicating copy to clipboard operation
django-el-pagination copied to clipboard

Need an ability to attach scroll event to some DIV, not only $(document)

Open niksite opened this issue 6 years ago • 2 comments

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?

niksite avatar Feb 13 '18 18:02 niksite

See tests project example https://github.com/shtalinberg/django-el-pagination/blob/develop/tests/project/templates/chunks/index.html just remove chunk functionality

shtalinberg avatar Feb 13 '18 18:02 shtalinberg

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.

niksite avatar Feb 13 '18 19:02 niksite