diff --git a/s/test.js b/s/test.js
index 41ca3cd..257f1bf 100644
--- a/s/test.js
+++ b/s/test.js
@@ -1,18 +1,22 @@
-$(document).ready(function() {
- $(window).scroll(function() {
- if($(window).scrollTop() == $(document).height() - $(window).height()) {
- $.ajax({
+var scrollListener = function () {
+ $(window).one("scroll", function () {
+ if($(window).scrollTop() + 256 >= $(document).height() - $(window).height()) {
+ $.ajax({
url: './api/p/'+$('#posts').data('last'),
dataType: 'json',
success: function(msg) {
var html = "";
for(var i = 0; i < msg.items.length; i++)
if(msg.items[i].id)
- html += "\n";
+ html += "
\n";
$('#posts').append(html);
$('#posts').data('last', msg.last);
}
});
- }
- });
+ }
+ setTimeout(scrollListener, 50);
+ });
+};
+$(document).ready(function () {
+ scrollListener();
});
\ No newline at end of file
diff --git a/s/test.tpl.html b/s/test.tpl.html
index 0b23cff..67c47c2 100644
--- a/s/test.tpl.html
+++ b/s/test.tpl.html
@@ -9,7 +9,7 @@