nexshop-web-contents
Version:
Nexshop Web Contents Project
9 lines (8 loc) • 350 B
JavaScript
export const isElementInParent = (element, parent) => {
let childRect = element.getBoundingClientRect();
let parentRect = parent.getBoundingClientRect();
return childRect.top >= parentRect.top
&& childRect.right <= parentRect.right
&& childRect.bottom <= parentRect.bottom
&& childRect.left >= parentRect.left;
};