summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2019-09-28 11:44:33 +0200
committerGitHub <noreply@github.com>2019-09-28 11:44:33 +0200
commitad6d50af01032ce57335260356eb7fd0be924627 (patch)
tree6c929f1cf9fe9444fdcef86b06e74b4da90bb55c
parentc8cd607681ac128228f57114ce14dd67ab05de04 (diff)
parent675d6f7f0eb39e7997b5813658cf430c9a8882a9 (diff)
downloadnextcloud-server-ad6d50af01032ce57335260356eb7fd0be924627.tar.gz
nextcloud-server-ad6d50af01032ce57335260356eb7fd0be924627.zip
Fix fetching additional search results on scrolling down (#15557)
Fix fetching additional search results on scrolling down
-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
},