From 2e99756cb3bb34b634b99da79e85d9f349e2e961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20B=C3=BChlmann?= Date: Wed, 15 May 2019 23:48:46 +0200 Subject: [PATCH] Fix fetching additional search results on scrolling down MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: René Bühlmann --- core/search/js/searchprovider.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/core/search/js/searchprovider.js b/core/search/js/searchprovider.js index 7b4970b37f..1ba7d63b3f 100644 --- a/core/search/js/searchprovider.js +++ b/core/search/js/searchprovider.js @@ -260,8 +260,8 @@ var result = $searchResults.find('tr.result')[currentResult]; if (result) { var $result = $(result); - var currentOffset = $('#app-content').scrollTop(); - $('#app-content').animate( + var currentOffset = $(window).scrollTop(); + $(window).animate( { // Scrolling to the top of the new result scrollTop: @@ -302,16 +302,15 @@ lastQuery !== false && lastResults.length > 0 ) { - var resultsBottom = $searchResults.offset().top + $searchResults.height(); - var containerBottom = $searchResults.offsetParent().offset().top + $searchResults.offsetParent().height(); - if (resultsBottom < containerBottom * 1.2) { - self.search(lastQuery, lastInApps, lastPage + 1); + if ($(window).scrollTop() + $(window).height() > $searchResults.height() - 300) { + self.search(lastQuery, lastInApps, lastPage + 1); } placeStatus(); } } - $('#app-content').on('scroll', _.bind(onScroll, this)); + $(window).on('scroll', _.bind(onScroll, this)); // For desktop browser + $("body").on('scroll', _.bind(onScroll, this)); // For mobile browser /** * scrolls the search results to the top @@ -319,9 +318,9 @@ function scrollToResults() { setTimeout(function() { if (isStatusOffScreen()) { - var newScrollTop = $('#app-content').prop('scrollHeight') - $searchResults.height(); + var newScrollTop = $(window).prop('scrollHeight') - $searchResults.height(); console.log('scrolling to ' + newScrollTop); - $('#app-content').animate( + $(window).animate( { scrollTop: newScrollTop },