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
window.models = { | |
initModel: function ( | |
modelName, | |
positionX, | |
positionY, | |
positionZ, | |
rotationX, | |
rotationY, | |
rotationZ, | |
rotationAnimationX, |
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 handle = () => { | |
console.log("Yo my size changed, do something with me") | |
} | |
const resizeObserver = new ResizeObserver(handle) | |
resizeObserver.observe(myElement) |
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 mobileQuery = window.matchMedia("(max-width: 74.999em)") // Change to your needs | |
const handleMobileChange = (mediaQueryList: MediaQueryListEvent | MediaQueryList) => { | |
if (mediaQueryList.matches) { | |
// Its Mobile | |
} else { | |
// Its Desktop | |
} | |
} |
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 myElementSelector = ".my-element" | |
document.addEventListener("click", ({target}) => { | |
if (target instanceof Element && !target?.closest(myElementSelector)) { | |
console.log("click outside") | |
} else { | |
console.log("click in") | |
} | |
}) |
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 const sameHeight = (group: Element, elements: string | NodeListOf<HTMLElement>, byRow = false) => { | |
const targets = elements instanceof NodeList ? Array.from(elements) : Array.from(group.querySelectorAll<HTMLElement>(elements)) | |
const getHighestElement = (elements: HTMLElement[] = targets): number => { | |
const heights = elements.map((box) => box.clientHeight) | |
return Math.max(...heights) | |
} | |
const resetHeight = (elements: HTMLElement[] = targets) => { | |
elements.forEach((element) => element.style.removeProperty("height")) |
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 tabsGroup = document.querySelectorAll(".js-tabs") | |
tabsGroup.forEach(tabGroup => { | |
const tabItems = tabGroup.querySelectorAll(".js-tabs__tab-item") | |
const panels = tabGroup.querySelectorAll(".js-tabs__panel") | |
const closeAllPanels = () => panels.forEach(content => content.classList.remove("--active")) | |
const resetAllTabItems = () => tabItems.forEach(link => link.classList.remove("--active")) |