Created
October 11, 2016 16:05
-
-
Save lucianobarauna/4476d0633e21bb9f84f2dbc10d2975e4 to your computer and use it in GitHub Desktop.
Feed Thumblr
This file contains hidden or 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
| $(document).ready(function() { | |
| $.ajax({ | |
| url: 'url json aqui', | |
| dataType: 'jsonp', | |
| data: 'chave_api', | |
| beforeSend: function() { | |
| console.log("FOI"); | |
| }, | |
| success: function(json) { | |
| posts = json.posts; | |
| } | |
| }); | |
| var pagina = 0; | |
| var thisIsALabel = 'photo-url-500'; | |
| $(window).scroll(function(){ | |
| console.log(pagina); | |
| console.log(posts.length); | |
| if ($(window).scrollTop() == $(document).height() - $(window).height()) { | |
| var curPagina = pagina; | |
| console.log(curPagina); | |
| for (var i = pagina; i < pagina + 3; i++) { | |
| if (curPagina < posts.length) { | |
| console.log(posts[i][thisIsALabel]); | |
| $("<img>").fadeIn("slow") | |
| .attr('src', posts[i][thisIsALabel]) | |
| .prependTo("#wrapper"); | |
| console.log(posts.length); | |
| console.log(pagina); | |
| curPagina += 1; | |
| } | |
| } | |
| pagina += 3; | |
| if(pagina > posts.length){ | |
| alert('chegou!') | |
| } | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment