Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda