Skip to content

Instantly share code, notes, and snippets.

@eladmeidar
Created October 17, 2019 06:58
Show Gist options
  • Save eladmeidar/6817e78a8bfb9b0933676278e787b811 to your computer and use it in GitHub Desktop.
Save eladmeidar/6817e78a8bfb9b0933676278e787b811 to your computer and use it in GitHub Desktop.
let isRunning = false
const foo = function() {
isRunning = true
console.log('called')
isRunning = false
}
const events = ['click', 'mousedown']
let func = function(eventsArr, cb) {
eventsArr.forEach(eventName => {
document.addEventListener(eventname, (e) => {
if (!isRunning) {
cb()
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment