Skip to content

Commit bc2377f

Browse files
rbuehlmaNatron
authored andcommitted
Fix fetching additional search results on scrolling down
Signed-off-by: René Bühlmann <rene@buehlmann.net>
1 parent 51d0a44 commit bc2377f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

core/search/js/searchprovider.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@
260260
var result = $searchResults.find('tr.result')[currentResult];
261261
if (result) {
262262
var $result = $(result);
263-
var currentOffset = $('#app-content').scrollTop();
264-
$('#app-content').animate(
263+
var currentOffset = $(window).scrollTop();
264+
$(window).animate(
265265
{
266266
// Scrolling to the top of the new result
267267
scrollTop:
@@ -302,26 +302,25 @@
302302
lastQuery !== false &&
303303
lastResults.length > 0
304304
) {
305-
var resultsBottom = $searchResults.offset().top + $searchResults.height();
306-
var containerBottom = $searchResults.offsetParent().offset().top + $searchResults.offsetParent().height();
307-
if (resultsBottom < containerBottom * 1.2) {
308-
self.search(lastQuery, lastInApps, lastPage + 1);
305+
if ($(window).scrollTop() + $(window).height() > $searchResults.height() - 300) {
306+
self.search(lastQuery, lastInApps, lastPage + 1);
309307
}
310308
placeStatus();
311309
}
312310
}
313311

314-
$('#app-content').on('scroll', _.bind(onScroll, this));
312+
$(window).on('scroll', _.bind(onScroll, this)); // For desktop browser
313+
$("body").on('scroll', _.bind(onScroll, this)); // For mobile browser
315314

316315
/**
317316
* scrolls the search results to the top
318317
*/
319318
function scrollToResults() {
320319
setTimeout(function() {
321320
if (isStatusOffScreen()) {
322-
var newScrollTop = $('#app-content').prop('scrollHeight') - $searchResults.height();
321+
var newScrollTop = $(window).prop('scrollHeight') - $searchResults.height();
323322
console.log('scrolling to ' + newScrollTop);
324-
$('#app-content').animate(
323+
$(window).animate(
325324
{
326325
scrollTop: newScrollTop
327326
},

0 commit comments

Comments
 (0)