mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
06979fa082
This improves the user experience by loading in the next entries shortly before him getting to the bottom. It makes the scrolling more smooth without a break in between. It also fixes an error on my browser that scrolling never hits the defined number. When I debugged it I hit `.scrolltop` of 1092.5 and the `doc.height - win.height` of 1093, so the condition was never true.
19 lines
730 B
JavaScript
19 lines
730 B
JavaScript
$(document).ready(function() {
|
|
var win = $(window);
|
|
win.scroll(function() {
|
|
if ($(document).height() - win.height() - win.scrollTop() < 150) {
|
|
var formData = $('#pagination form:last').serialize();
|
|
if (formData) {
|
|
$('#pagination').html('<div class="loading-spinner"></div>');
|
|
$.post('./', formData, function (data) {
|
|
var body = $(data);
|
|
$('#pagination').remove();
|
|
$('#main_results').append('<hr/>');
|
|
$('#main_results').append(body.find('.result'));
|
|
$('#main_results').append(body.find('#pagination'));
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|