Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 4x 14x 14x 14x 14x 9x 5x 7x 11x 7x 7x 11x 11x 30x 32x | /* UTILS.JS - Modern Vanilla JS Utilities ===============================================
Copyright 2025, Mark Forscher */
/* ======================================================================================= */
export const Utils = {
// Viewport visibility checker (replaces jQuery visible plugin)
isElementVisible(element, partial = true) {
const rect = element.getBoundingClientRect();
const windowHeight = window.innerHeight;
const windowWidth = window.innerWidth;
if (partial) {
return rect.bottom >= 0 && rect.top <= windowHeight &&
rect.right >= 0 && rect.left <= windowWidth;
} else {
return rect.top >= 0 && rect.bottom <= windowHeight &&
rect.left >= 0 && rect.right <= windowWidth;
}
},
// Debounce function for scroll events
debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
},
// Query selector helper
$(selector) {
return document.querySelectorAll(selector);
},
// Single element selector
$1(selector) {
return document.querySelector(selector);
}
};
|