This file contains 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
export default callback => requestAnimationFrame((function loop(then) { | |
return now => { | |
const delta = now - then; | |
callback(delta); | |
return requestAnimationFrame(loop(now)); | |
} | |
})(performance.now())); |
This file contains 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
const overlap = baseLines => comparisonLines => baseLines.reduce((bool, baseLine, index) => { | |
const comparisonLine = comparisonLines[index]; | |
if (bool === true) return Math.max(baseLine[0], comparisonLine[0]) < Math.min(baseLine[1], comparisonLine[1]); | |
else return false; | |
}, true); |
This file contains 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
form => fetch(form.getAttribute('action') + [].reduce.call(form.querySelectorAll('[name]'), (params, input) => params + encodeURI(input.getAttribute('name') + '=' + input.value + '&'), '?') |
This file contains 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
debounce = (delay, cancel) => (listener, wait) => { | |
let delayId | |
return function(...args) { | |
cancel(delayId) | |
return delayId = delay(() => listener.apply(this, args), wait) | |
} | |
} | |
debounceTimeout = debounce(setTimeout, clearTimeout) | |
debounceAnimationFrame = debounce(requestAnimationFrame, cancelAnimationFrame) |