Add A Smart Delay To jQuery on() Method - SmartOn
File Size: | 44.9 KB |
---|---|
Views Total: | 390 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
SmartOn is a jQuery plugin that provides 4 useful methods to extend the default jQuery on() method.
- .smartOn(): triggers the event with a delay (triggered only once)
- .afterOn(): executes a functiont after the event was not triggered within a certain period of time
- .everyOn(): executes a function after the event has triggered n times
- .delayOn(): triggers the event with a delay
How to use it:
1. Download and place the jQuery SmartOn plugin's script after jQuery JavaScript library.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"> </script> <script src="jquery.smartOn.js"></script>
2. Usages:
// smartOn $('.element').smartOn( 'click', // event function(e) { // event handler }, 1000 // delay in ms ); // afterOn $('.element').afterOn( 'click', // event function(e) { // event handler }, 300 // delay in ms ); // everyOn $( '.element' ).everyOn( 'click', // event { // data passed to on() }, function(e) { // event handler }, 3 // times ); // delayOn $('.element').delayOn( 'click', // event function(e) { // event handler }, 1000 // delay in ms );
Changelog:
2018-07-06
- Update
This awesome jQuery plugin is developed by mi-roh. For more Advanced Usages, please check the demo page or visit the official website.