annasthms

infinite scroll

Apr 28th, 2018
1,190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.34 KB | None | 0 0
  1. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  2. <script src="//static.tumblr.com/yfztp0u/brUohnb4m/infinitescroll.js"></script>
  3. <script>
  4. $(document).ready(function(){
  5.   $container = $('section#posts'); // change section#posts to your post container
  6.   $container.infinitescroll({
  7.     navSelector: 'div#pagination', // change div#pagination to your pagination wrapper
  8.     nextSelector: 'a.next', // change a.next to your "next" link
  9.     itemSelector: '.post', // change .post to your post tag/class
  10.     loading: { // this is to remove the default loading text/image (i think?)
  11.       img: '',
  12.       msgText: '',
  13.     },
  14.     debug: true, // this'll log everything it's doing into the console; don't worry about it
  15.     bufferPx: 0 // how far from the bottom of the page in px you have to scroll for it to load more posts
  16.   }, function(items) {
  17.     var $items = $(items);
  18.     $items.addClass('new'); // adds 'new' class to the new posts
  19.    
  20.     // add any functions you have here (you'll need to call them again)
  21.     // i.e. pxu photosets
  22.    
  23.     // makes sure the like button works
  24.     $itemsIDs = $items.map(function(){
  25.       return this.id;
  26.     }).get();
  27.     Tumblr.LikeButton.get_status_by_post_ids($itemsIDs);
  28.     $items.removeClass('new'); // removes 'new' class after everything is done
  29.   });
  30. });
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment