Skip to content

Little script that detects if an element is in the viewport and adds a class to it.

License

Notifications You must be signed in to change notification settings

anandau/jQuery-viewport-checker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jQuery-viewport-checker

Little script that detects if an element is in the viewport and adds a class to it.

Installation

Just include the script and jQuery in your website tag and call it on the elements you want to check.

<head>
    <script src="http://code.jquery.com/jquery.js"></script>
    <script src="viewportchecker.js"></script>

    <script>
        $(document).ready(function(){
            $('.dummy').viewportChecker();
        });
    </script>
</head>

Options

The current available options are:

$('.dummy').viewportChecker({
    classToAdd: 'visible', // Class to add to the elements when they are visible
    offset: 100, // The offset of the elements (let them appear earlier or later)
    callbackFunction: function(elem){} // Callback to do after a class was added to an element
});

About

Little script that detects if an element is in the viewport and adds a class to it.

Resources

License

Stars

Watchers

Forks

Packages

No packages published