¿Hay alguna alternativa al complemento de desplazamiento sin fin de jQuery?
http://www.beyondcoding.com/2009/01/15/release-jquery-plugin-endless-scroll/
Esto debería hacer el mismo truco sin complemento.
$(window).scroll(function () { if ($(window).scrollTop() >= $(document).height() - $(window).height() - 100) { //Add something at the end of the page } });De acuerdo con el comentario de @pere, es mejor usar el siguiente código para evitar una cantidad excesiva de activación de eventos .
Inspirado en esta respuesta https://stackoverflow.com/a/13298018/153723
var scrollListener = function () { $(window).one("scroll", function () { //unbinds itself every time it fires if ($(window).scrollTop() >= $(document).height() - $(window).height() - 100) { //Add something at the end of the page } setTimeout(scrollListener, 200); //rebinds itself after 200ms }); }; $(document).ready(function () { scrollListener(); });Combinando la respuesta de Ergec y el comentario de Pere:
function watchScrollPosition(callback, distance, interval) { var $window = $(window), $document = $(document); var checkScrollPosition = function() { var top = $document.height() - $window.height() - distance; if ($window.scrollTop() >= top) { callback(); } }; setInterval(checkScrollPosition, interval); } La distance es el número de píxeles desde la parte inferior de la pantalla cuando se disparará la devolución de llamada.
interval es la frecuencia con la que se ejecutará la comprobación (en milisegundos; 250-1000 es razonable).
Por ejemplo, el complemento de desplazamiento infinito