scrollama
Version:
Lightweight scrollytelling library using IntersectionObserver
18 lines (15 loc) • 431 B
JavaScript
// DOM helper functions
// public
function selectAll(selector, parent = document) {
if (typeof selector === 'string') {
return Array.from(parent.querySelectorAll(selector));
} else if (selector instanceof Element) {
return [selector];
} else if (selector instanceof NodeList) {
return Array.from(selector);
} else if (selector instanceof Array) {
return selector;
}
return [];
}
export { selectAll };