[stable16] Fix fetching additional search results on scrolling… (#17304)
[stable16] Fix fetching additional search results on scrolling down
This commit is contained in:
commit
f65e06fd6c
|
@ -260,8 +260,8 @@
|
||||||
var result = $searchResults.find('tr.result')[currentResult];
|
var result = $searchResults.find('tr.result')[currentResult];
|
||||||
if (result) {
|
if (result) {
|
||||||
var $result = $(result);
|
var $result = $(result);
|
||||||
var currentOffset = $('#app-content').scrollTop();
|
var currentOffset = $(window).scrollTop();
|
||||||
$('#app-content').animate(
|
$(window).animate(
|
||||||
{
|
{
|
||||||
// Scrolling to the top of the new result
|
// Scrolling to the top of the new result
|
||||||
scrollTop:
|
scrollTop:
|
||||||
|
@ -302,16 +302,15 @@
|
||||||
lastQuery !== false &&
|
lastQuery !== false &&
|
||||||
lastResults.length > 0
|
lastResults.length > 0
|
||||||
) {
|
) {
|
||||||
var resultsBottom = $searchResults.offset().top + $searchResults.height();
|
if ($(window).scrollTop() + $(window).height() > $searchResults.height() - 300) {
|
||||||
var containerBottom = $searchResults.offsetParent().offset().top + $searchResults.offsetParent().height();
|
self.search(lastQuery, lastInApps, lastPage + 1);
|
||||||
if (resultsBottom < containerBottom * 1.2) {
|
|
||||||
self.search(lastQuery, lastInApps, lastPage + 1);
|
|
||||||
}
|
}
|
||||||
placeStatus();
|
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
|
* scrolls the search results to the top
|
||||||
|
@ -319,9 +318,9 @@
|
||||||
function scrollToResults() {
|
function scrollToResults() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (isStatusOffScreen()) {
|
if (isStatusOffScreen()) {
|
||||||
var newScrollTop = $('#app-content').prop('scrollHeight') - $searchResults.height();
|
var newScrollTop = $(window).prop('scrollHeight') - $searchResults.height();
|
||||||
console.log('scrolling to ' + newScrollTop);
|
console.log('scrolling to ' + newScrollTop);
|
||||||
$('#app-content').animate(
|
$(window).animate(
|
||||||
{
|
{
|
||||||
scrollTop: newScrollTop
|
scrollTop: newScrollTop
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue