JavaScript Library To Detect If An Element Is In View – inView.js

Category: Javascript | February 24, 2016
Author: cronin4392
Views Total: 3,943
Official Page: Go to website
Last Update: February 24, 2016
License: MIT

Preview:

JavaScript Library To Detect If An Element Is In View – inView.js

Description:

inView.js is a pure JavaScript library that watches for the scroll event and executes callbacks when an element is scrolled in or out of the viewport.

How to use it:

Just load the inView.js JavaScript file into your html document and we’re ready to go.

<script src="inView.js"></script>

Add the CSS class ‘inView’ to your element.

<img class="inView" src="1.jpg">

Execute callback functions if the image is scrolled into or out of the viewport.

var el = new inView(document.getElementById('inView'));
    el.onInView(function() {
        // do something
    });
    el.onOutView(function() {
        // do something
    });

You Might Be Interested In:


Leave a Reply