execute code part visible - Download Execute Code When A Part Of Your Element Becomes Visible - on-scrolled-to.js

Download Execute Code When A Part Of Your Element Becomes Visible – on-scrolled-to.js

Posted on

This time I will share jQuery Plugin and tutorial about Execute Code When A Part Of Your Element Becomes Visible – on-scrolled-to.js, hope it will help you in programming stack.

execute code part visible - Download Execute Code When A Part Of Your Element Becomes Visible - on-scrolled-to.js
File Size: 4.52 KB
Views Total: 720
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

on-scrolled-to.js is a jQuery plugin that detects how much (from 0 to 1) your element is visible within the viewport and triggers a callback function when you scroll down the page.

The typical use of this plugin is to animate the element when a specified part of the element becomes visible when the user scrolls through your long web page.

How to use it:

1. Download and import the minified version of the on-scrolled-to.js plugin after jQuery library.

2         integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
3         crossorigin="anonymous">
4 </script>
5 <script src="on-scrolled-to.min.js"></script>

2. Call the function on the target element you want to keep track of the visibility. In this example, the plugin will will execute a function when 50% of the element is visible on the page.

1 <div class="example">
2   Element
3 </div>
1 $('.block').on<a href="https://www.jqueryscript.net/tags.php?/Scroll/">Scroll</a>edTo(0.5, function() {
2    
3   // add animation classes to the element
4   this.attr('class', 'animation-class');
5    
6 });

3. To execute a function when this element is fully visible on the page, just set the portionVisible parameter to 1.

1 <div class="example">
2   Element
3 </div>
1 $('.block').onScrolledTo(1, function() {
2    
3   // add animation classes to the element
4   this.attr('class', 'animation-class');
5    
6 });

This awesome jQuery plugin is developed by wowpress-host. For more Advanced Usages, please check the demo page or visit the official website.

source : jquery.net