Skip to content

Instantly share code, notes, and snippets.

View marco-prontera's full-sized avatar
♦️
Focusing

Marco Prontera marco-prontera

♦️
Focusing
View GitHub Profile
@marco-prontera
marco-prontera / isVisibleInViewport.js
Last active April 4, 2024 11:43
Check If an Element is Visible in the Viewport with JavaScript
function isVisibleInViewport(element) {
const elementStyle = window.getComputedStyle(element);
//Particular cases when the element is not visible at all
if (
elementStyle.height == '0px' ||
elementStyle.display == 'none' ||
elementStyle.opacity == '0' ||
elementStyle.visibility == 'hidden' ||
elementStyle.clipPath == 'circle(0px at 50% 50%)' ||
elementStyle.transform == 'scale(0)' ||
@marco-prontera
marco-prontera / icq.js
Last active February 6, 2023 08:01
JavaScript - Instant command queue pattern
var icqLibrary = icqLibrary || {};
icqLibrary.queue = icqLibrary.queue || [];
icqLibrary.queue.push(() => {
console.log('Queue 1');
});
icqLibrary.queue.push(() => {
console.log('Queue 2');
});