Skip to content
Snippets Groups Projects
Commit 9702bbf2 authored by sozy's avatar sozy
Browse files

fix: infinite scroll bug

parent 6f9617e7
Branches
Tags
No related merge requests found
...@@ -129,7 +129,9 @@ function fetchSearch(replace = false) { ...@@ -129,7 +129,9 @@ function fetchSearch(replace = false) {
xhttp.onreadystatechange = function () { xhttp.onreadystatechange = function () {
if (xhttp.readyState === 4) { if (xhttp.readyState === 4) {
const itemsPlaceholder = document.querySelector("p.items-placeholder"); const itemsPlaceholder = document.querySelector("p.items-placeholder");
itemsPlaceholder.remove(); if (itemsPlaceholder) {
itemsPlaceholder.remove();
}
const wrapper = document.createElement('div'); const wrapper = document.createElement('div');
wrapper.classList.add('watchlist-item'); wrapper.classList.add('watchlist-item');
wrapper.draggable = "true"; wrapper.draggable = "true";
...@@ -197,7 +199,12 @@ inputSearch.addEventListener('keydown', function (e) { ...@@ -197,7 +199,12 @@ inputSearch.addEventListener('keydown', function (e) {
inputSearch.addEventListener('input', search); inputSearch.addEventListener('input', search);
searchItems.addEventListener('scroll', () => { searchItems.addEventListener('scroll', () => {
if (searchItems.scrollHeight === (searchItems.scrollTop + searchItems.clientHeight) && !endOfList && !isLoading) { if (searchItems.offsetHeight + searchItems.scrollTop - searchItems.clientHeight + 100 > 0 && !endOfList && !isLoading) {
fetchSearch();
}
})
searchItems.addEventListener('touchmove', () => {
if (searchItems.offsetHeight + searchItems.scrollTop - searchItems.clientHeight + 100 > 0 && !endOfList && !isLoading) {
fetchSearch(); fetchSearch();
} }
}) })
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment