Mizanur Rahaman Mizan / November 2, 2016

How to load content on scrolling using jQuery and related plugins

In this article, I am going to show you how you can load certain portion of code only when the content is scrolled down and appeared on the screen. i.e to the viewport. To load content on scrolling we need a jQuery plugin named viewport. It is one of the easiest to use for such types of operation. I am using Barfiller jQuery plugin to demonstrate the plugin. It will start progressing once scroll down to that portion.

The end result will be something like this:  Demo | Download Code

To load content on scrolling, first Download bar filler and viewport plugin.

Link the viewport JS file to the head ( I have added on the head). It should work before the close of the body tag too. I have included the bar-filler plugin on the footer.

 

The Viewport is just some special selector added to our jQuery. It adds the following selector. Please check  the site of Viewport to have more information.

 

Now The code that you want to appear once after it loaded to the viewport, i.e to load content on scrolling , add a div with any id. I have added a div with id named “progress”.

Now add the following code to the end of the body. i.e before </body>

Here, after the document is ready we are checking for the scroll event. then each scrolled event we are selecting the special selector provided by viewport plugin :in-viewport. then for each item, we are calling the bar filler. You can call any code here.

You are done! Hope you understood. Let me know if you have any problem. If you have a better solution, please let me know by commenting.

FILED UNDER : Miscellaneous

Submit a Comment

Must be required * marked fields.

:*
:*

Mizanur Rahaman Mizan

Life-long student of technology, a teacher , a tourist & a foodie.

Get me @: My Page | FB Profile | Twitter

For special content , subscribe!

Subscribe to our mailing list

* indicates required
Read more:
Hello world! Welcome To MizPress

I am Mizanur Rahaman Mizan - A dreamer from south east Asia. My country that makes me always feel proud...

Bengali personal blog started!

I have started my personal Bengali blog at http://bn.mizpress.com/   Have a look if you are looking for some cool bengali...

Close