Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda