Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
How can I change infinite scroll module to scroll from the bottom to the top of the screen?

Here is the logic of infinite scroll from the top to the bottom of the screen :

height = function (elem) {
    elem = elem[0] || elem;
    if (isNaN(elem.offsetHeight)) {
        return elem.document.documentElement.clientHeight;
    } else {
        return elem.offsetHeight;
    }
};
offsetTop = function (elem) {
    if (!elem[0].getBoundingClientRect || elem.css('none')) {
        return;
    }
    return elem[0].getBoundingClientRect().top + pageYOffset(elem);
};
pageYOffset = function (elem) {
    elem = elem[0] || elem;
    if (isNaN(window.pageYOffset)) {
        return elem.document.documentElement.scrollTop;
    } else {
        return elem.ownerDocument.defaultView.pageYOffset;
    }
}
handler = function () {
    if (container === windowElement) {
        containerBottom = height(container) + pageYOffset(container[0].document.documentElement);
        console.log('height(elem', height(elem))
        elementBottom = offsetTop(elem) + height(elem);
    } else {
        containerBottom = height(container);
        containerTopOffset = 0;
        if (offsetTop(container) !== void 0) {
            containerTopOffset = offsetTop(container);
        }
        elementBottom = offsetTop(elem) - containerTopOffset + height(elem);
    }
    if (useDocumentBottom) {
        elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement);
    }
    remaining = elementBottom - containerBottom;
    shouldScroll = remaining <= height(container) * scrollDistance + 1;
}

How can I modify my code in order to infinite scroll properly from the bottom to the top of the screen.

I try to do this, i change the hendler function i remove all my code and I do this

elemenTop = pageYOffset(container[0].document.documentElement)
remaining = elemenTop - 250;
shouldScroll = remaining <= height(container) * scrollDistance + 1;

When u test infinite scroll module. if u want to use the scroll bar to go directly to the bottom of the screen it keeps loading the data till u have no data to load.With my modification when I go straight to the top of the screen with the scroll bar it doesn't keep loading my data, it stops to load the data and i have to scroll to make it work again.

I shouldn't have to scroll to make it work again when i'm in the top it should scroll itself since I have all the data loaded

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!