MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / debounce

Function debounce

assets/js/ImageSlide.js:1–14  ·  view source on GitHub ↗
(func, wait = 20, immediate = true)

Source from the content-addressed store, hash-verified

1function debounce(func, wait = 20, immediate = true) {
2 var timeout;
3 return function() {
4 var context = this, args = arguments;
5 var later = function() {
6 timeout = null;
7 if (!immediate) func.apply(context, args);
8 };
9 var callNow = immediate && !timeout;
10 clearTimeout(timeout);
11 timeout = setTimeout(later,wait);
12 if (callNow) func.apply(context, args);
13 };
14};
15
16const sliderImages = document.querySelectorAll('.slide-in');
17

Callers 1

ImageSlide.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected