@kelvininc/ui-components
Version:
Kelvin UI Components
10 lines (9 loc) • 469 B
JavaScript
import { isNil } from "lodash-es";
export const isElementVisible = (element, selector) => {
const foundElement = element.querySelector(selector);
return !isNil(foundElement) && foundElement.clientHeight > 0 && foundElement.clientWidth > 0;
};
export const hasAnyVisibleElement = (element, selector) => {
const foundElements = element.querySelectorAll(selector);
return Array.from(foundElements).some(el => el.clientHeight > 0 && el.clientWidth > 0);
};