ドキュメントの高さは 11886 で、ドキュメントの一番下までスクロールしたときのスクロール位置は 9542 です。
ドキュメントの一番下までスクロールしたときに実行したい機能があります。これにより、ドキュメントのサイズが再び大きくなり、より多くのコンテンツが読み込まれます。次に、ドキュメントの高さを更新し、ユーザーが下にスクロールできるようにする必要があります。
再び一番下に到達したら、関数を実行してドキュメントの高さを更新したいと思います。
Locomotive.jsスクロールを使用します。Const scroll はスクロール機能を作成しています。
(function () {
const scroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
class: 'aos-animate',
});
$(window).on("load", function () {
scroll.update();
});
let height = $(document).height();
console.log(height);
scroll.on('scroll', (position) => {
// let scroll_position = position.scroll.y;
// console.log(scroll_position);
const pageHeight = $('body').height() - $(window).height();
let scrollPos = position.scroll.y;
let scrollPercentage = (scrollPos * 100) / pageHeight;
let finalPercentage = Math.ceil(scrollPercentage);
console.log(finalPercentage);
if(finalPercentage == 100) {
setTimeout(() => {
my_repeater_show_more();
scroll.update();
$('.mouse-follow').each(function (index, el) {
var html = $(this).data('content');
$(el).mousefollow({
html: html,
className: 'js-follow',
});
});
}, 1000);
}
})
})
})();