Fix scroll

This commit is contained in:
lalka2016 2023-08-11 14:14:36 +03:00
parent 8bccab7bc0
commit 553731deed
3 changed files with 20 additions and 5 deletions

View file

@ -51,7 +51,7 @@
{include "../components/paginator.xml", conf => $paginatorConf} {include "../components/paginator.xml", conf => $paginatorConf}
{/if} {/if}
<script> <script n:if="$thisUser->getPaginatorType() == 0">
u("#pageSelect").nodes[0].value = {$paginatorConf->perPage}; u("#pageSelect").nodes[0].value = {$paginatorConf->perPage};
u("#pageSelect").on("change", function(e) { u("#pageSelect").on("change", function(e) {

View file

@ -272,9 +272,11 @@ async function showArticle(note_id) {
$(document).on("click", ".showMore", async (e) => { $(document).on("click", ".showMore", async (e) => {
e.currentTarget.innerHTML = `<img id="loader" src="/assets/packages/static/openvk/img/loading_mini.gif">` e.currentTarget.innerHTML = `<img id="loader" src="/assets/packages/static/openvk/img/loading_mini.gif">`
let url = new URL(location.href) let url = new URL(location.href)
let newPage = Number(e.currentTarget.dataset.page) + 1 let newPage = Number(e.currentTarget.dataset.page) + 1
url.searchParams.set("p", newPage) url.searchParams.set("p", newPage)
url.searchParams.set("posts", 10)
let xhr = new XMLHttpRequest let xhr = new XMLHttpRequest
xhr.open("GET", url) xhr.open("GET", url)
@ -328,3 +330,20 @@ $(document).on("click", ".showMore", async (e) => {
xhr.send() xhr.send()
}) })
let showMoreObserver = new IntersectionObserver(entries => {
entries.forEach(x => {
if(x.isIntersecting) {
$(".showMore").click()
}
})
}, {
root: null,
rootMargin: "0px",
threshold: 0
})
let showMore = document.querySelector('.showMore');
if(showMore != null)
showMoreObserver.observe(showMore);

View file

@ -691,8 +691,4 @@ $(document).on("scroll", () => {
$(".floating_sidebar")[0].classList.remove("hide_anim"); $(".floating_sidebar")[0].classList.remove("hide_anim");
}, 250); }, 250);
} }
if($(window).scrollTop() == $(document).height() - $(window).height() && document.querySelector(".showMore") != null) {
$(".showMore").click()
}
}) })