hotspot: setHeight + callbackFN

This commit is contained in:
2025-10-01 12:51:29 +02:00
parent d50486c684
commit ad3e6a88e9
3 changed files with 41 additions and 4 deletions

View File

@@ -294,3 +294,28 @@ function idmObserveOnce(element, callback, options = { root: null, rootMargin:
observer.observe(element);
}
////////////////////////////////////////////////
// IDM SET HEIGHT
app_shop.fn.idmSetHeight = options => {
const { selector, selectors, container } = options || {}
if ((!selector && !selectors) || !container) return
const containerElement = document.querySelector(container)
if (!containerElement) return
const adjustAllHeights = itemSelector => {
const targets = containerElement.querySelectorAll(itemSelector)
if (!targets.length) return
targets.forEach(el => (el.style.minHeight = ''))
const max = Math.max(...[...targets].map(el => el.offsetHeight || 0))
targets.forEach(el => (el.style.minHeight = `${max}px`))
}
if (selector) adjustAllHeights(selector)
if (selectors?.length) selectors.forEach(adjustAllHeights)
}