@zohodesk/hooks
Version:
Unified Component Library - Hooks
16 lines (15 loc) • 490 B
JavaScript
import frameRelativeRects from "./frameRelativeRects";
export default function isInViewPort(el, customFrame) {
if (!el) {
return;
}
const elRects = frameRelativeRects(el, customFrame);
const {
rect
} = elRects;
const {
frameRect
} = elRects;
console.log(rect.top >= 0, rect.left >= 0, rect.bottom <= frameRect.height, rect.right <= frameRect.width);
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= frameRect.height && rect.right <= frameRect.width;
}