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
// https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#creating_an_intersection_observer | |
const options = {}; | |
const observer = new IntersectionObserver((entries, self) => { | |
entries.forEach(({isIntersecting, target}) => { | |
target.classList.toggle('show', isIntersecting); | |
}) | |
}, options); | |
document.querySelectorAll('.hidden').forEach(target => observer.observe(target)); |
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
export default function newQueue( | |
maxCurr = 10, | |
func, | |
{ logger, logtag = "" } = {} | |
) { | |
let curr = 0; | |
const queue = []; | |
async function scheduleWork() { | |
if (curr >= maxCurr || queue.length === 0) return; |