Created
October 1, 2017 08:16
-
-
Save tkssharma/0efa40f603460fd516734cc68f7cb0bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debouce(fn, delay){ | |
var timer = null | |
return function(){ | |
let content = this; | |
var args = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(()=>{ | |
fn.apply(this,arguments) | |
},delay) | |
} | |
} | |
// function to be called when user scrolls | |
function foo() { | |
console.log('You are scrolling!'); | |
} | |
var app = document.getElementsByTagName('app'); | |
app.addEventListener('click', debouce(fn,200)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment