Simplex Design blog : Infinite scrolling or load more effect for Blogger - part 1 |
Infinite scrolling or load more effect for Blogger - part 1 Posted: 15 Feb 2013 08:34 AM PST If you are using Facebook, Twitter or take a look around new websites, you may see most of them use a technique to load next posts automatically, without click on Next or Previous button as we did before. This technique was also applied to Blogger Dynamic interface. In this post, I will show you how to use this technique to make infinite scrolling or load more effect for normal Blogger blog using a Jquery plugin name Jquery Ajax Scrollling. Live Demo Because it too long, so I divide this post into 3 parts with detail as bellow: - Part 1: Basic usage of Jquery Ajax Scrolling and apply it to default Blogger template - Part 2: How to apply Infinite Scrolling technique to all Blogger templates. - Part 3: Combine this Jquery plugin with other plugin ( layout plugins such as Masonry, Isotape, or Disqus comment system, Google Analytics) Part 1: Basic usage of Jquery Ajax Scrolling and apply it to default Blogger templatesYou may heard a technology which was invented several years ago name Ajax. You can google this term to know more. But in this post, Ajax is a technology that allow us to exchange data with a server, and update parts of a web page - without reloading the whole page. Jquery is a framework that support Ajax strongly. With Jquery, users can access a part of HTML page from another page, get the data and then display without reloading. So you can imagine, if we are in page 1, we can use Ajax to access content of page 2, then display them under content of page 1 without reloading, it's the way that Infinite Scrolling technique apply.To make this function easier and friendly, Jeroen Fiege (http://www.fieg.nl) created Jquery Ajax Scrolling plugin. Instead of remembering parameters for Ajax in Jquery, you can use friendly statement in Jquery Ajax Scrolling. Now, it's time for practicing. Install Instruction1, Download Jquery Ajax Plugin at this address: https://nodeload.github.com/webcreate/infinite-ajax-scroll/zip/masterYou can take a look on documentation and example of this plugin here http://www.fieg.nl/infinite-ajax-scroll-a-jquery-plugin2, Upload Jquery Ajax Scrolling plugin files to your own hosting. Just one file need to upload jquery.ias.min.js 3, In this post, I will show you basic usage, with default Blogger templates (which is provided in Template tab of Blogger Dashboard). Tutorial for applying to custom templates will be part 2. Open template file by going to Blogger Dashboard -> Template -> Edit HTML Insert these code before </head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> Now you can save changes and see how it work. Remember this can not work if your blog has only one page ! Code explainationIn the code above- The first line: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>will call Jquery framework which is hosted by Google. You can not use Jquery without calling it before. - The second line: <script src="your-own-hosting/jquery.ias.min.js" type="text/javascript"></script>will call Jquery plugin: Ajax Scrolling. - Condition statement: <b:if cond='data:blog.pageType != "item"'> ..................... To make sure the script inside only work if current page is not a single post, otherwise, it only work when current page is homepage or archive page. - The script right after: jQuery.ias({ so I entered ".blog-posts" here. // This will be hidden when IAS loads. to get the items from the next page. How it work- First, when your Page 1 load in user browser, this plugin will search for HTML element which contain link to next page - Page 2 (use information in "pagination" and "next" options above).- Second, it store the link to Page 2. Hide the whole "pagination" element. - Third, load Page 2 in computer memory, then scan whole Page 2 for elements specified in "item" option - Forth, appending items found to "container" . ConclusionThat's all for default Blogger templates. Because HTML structure of Blogger default templates are the same, so you can apply this post to all them (except Dynamic Views templates).In the next part, I will show you how to apply infinite scrolling to custom Blogger template. Thanks for reading, and feel free to leave me feedbacks. |
You are subscribed to email updates from SimplexDesign - free premium blogspot template To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
ليست هناك تعليقات:
إرسال تعليق