summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRené Bühlmann <rene@buehlmann.net>2019-05-15 23:48:46 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-28 10:56:57 +0200
commit675d6f7f0eb39e7997b5813658cf430c9a8882a9 (patch)
tree6c929f1cf9fe9444fdcef86b06e74b4da90bb55c
parentc8cd607681ac128228f57114ce14dd67ab05de04 (diff)
downloadnextcloud-server-675d6f7f0eb39e7997b5813658cf430c9a8882a9.tar.gz
nextcloud-server-675d6f7f0eb39e7997b5813658cf430c9a8882a9.zip
Fix fetching additional search results on scrolling down
Signed-off-by: René Bühlmann <rene@buehlmann.net>
-rw-r--r--core/search/js/searchprovider.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/search/js/searchprovider.js b/core/search/js/searchprovider.js
index 7b4970b37f6..1ba7d63b3fe 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
},