Last active
October 9, 2017 04:00
-
-
Save larry852/8cd65e8056fe72646d55fd7eeff9add6 to your computer and use it in GitHub Desktop.
Lazyload javascripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ########################################################### | |
// Numero de pagina actual | |
// ########################################################### | |
var pageNumber = 1; | |
// ########################################################### | |
// Deteccion del borde inferior | |
// ########################################################### | |
$(function () { | |
var $win = $(window); | |
$win.scroll(function () { | |
if ($win.height() + $win.scrollTop() == $(document).height()) | |
load(); | |
}); | |
}); | |
// ########################################################### | |
// Carga de nueva pagina de publicaciones | |
// ########################################################### | |
function load() { | |
pageNumber++; | |
$.ajax({ | |
dataType: "json", | |
url: base + "SourceBackend/get-page?pageNumber="+pageNumber | |
}).done(function(data) { | |
setPostLoad(data); | |
}); | |
} | |
// ########################################################### | |
// Pintado de publiaciones para lazyload | |
// ########################################################### | |
function setPostLoad(data) { | |
for (var i in data) { | |
var post = data[i]; | |
var fecha = new Date(post.date); | |
var options = { year: 'numeric', month: 'long', day: 'numeric' }; | |
addPost(post, options, fecha) | |
} | |
setMain(); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment