This time I will share jQuery Plugin and tutorial about jQuery Plugin To Detect If Elements Are In View – Viewport Detector, hope it will help you in programming stack.
A simple jQuery based viewport detect which performs a callback and alters the CSS classes if a specified elements is scrolled into view.
How to use it:
1. Load the jquery-viewport-detector.js
script after jQuery JavaScript library.
1 |
<script src= "//code.jquery.com/jquery-1.11.3.min.js" ></script> |
2 |
<script src= "jquery-viewport-detector.js" ></script> |
2. Execute a callback if the #el element is visible on your page.
1 |
$( '#el' ).viewportDetector({ |
3. Change the CSS styles of the #el element if it is scrolled into view.
4. Full plugin options.
08 |
activeClass: 'active-card' , |
This awesome jQuery plugin is developed by wsaleme. For more Advanced Usages, please check the demo page or visit the official website.