diff --git a/src/public/js/components/modal/watchlistAddItem.js b/src/public/js/components/modal/watchlistAddItem.js index aec6512a70f472c365b82e57c0dc42905ba899e0..b2e14a92fa3e7e63beb9890a72499c7d1e8b9ed0 100644 --- a/src/public/js/components/modal/watchlistAddItem.js +++ b/src/public/js/components/modal/watchlistAddItem.js @@ -129,7 +129,9 @@ function fetchSearch(replace = false) { xhttp.onreadystatechange = function () { if (xhttp.readyState === 4) { const itemsPlaceholder = document.querySelector("p.items-placeholder"); - itemsPlaceholder.remove(); + if (itemsPlaceholder) { + itemsPlaceholder.remove(); + } const wrapper = document.createElement('div'); wrapper.classList.add('watchlist-item'); wrapper.draggable = "true"; @@ -197,7 +199,12 @@ inputSearch.addEventListener('keydown', function (e) { inputSearch.addEventListener('input', search); 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(); } })