|
260 | 260 | var result = $searchResults.find('tr.result')[currentResult]; |
261 | 261 | if (result) { |
262 | 262 | var $result = $(result); |
263 | | - var currentOffset = $('#app-content').scrollTop(); |
264 | | - $('#app-content').animate( |
| 263 | + var currentOffset = $(window).scrollTop(); |
| 264 | + $(window).animate( |
265 | 265 | { |
266 | 266 | // Scrolling to the top of the new result |
267 | 267 | scrollTop: |
|
302 | 302 | lastQuery !== false && |
303 | 303 | lastResults.length > 0 |
304 | 304 | ) { |
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); |
309 | 307 | } |
310 | 308 | placeStatus(); |
311 | 309 | } |
312 | 310 | } |
313 | 311 |
|
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 |
315 | 314 |
|
316 | 315 | /** |
317 | 316 | * scrolls the search results to the top |
318 | 317 | */ |
319 | 318 | function scrollToResults() { |
320 | 319 | setTimeout(function() { |
321 | 320 | if (isStatusOffScreen()) { |
322 | | - var newScrollTop = $('#app-content').prop('scrollHeight') - $searchResults.height(); |
| 321 | + var newScrollTop = $(window).prop('scrollHeight') - $searchResults.height(); |
323 | 322 | console.log('scrolling to ' + newScrollTop); |
324 | | - $('#app-content').animate( |
| 323 | + $(window).animate( |
325 | 324 | { |
326 | 325 | scrollTop: newScrollTop |
327 | 326 | }, |
|
0 commit comments