@fe6/water-pro
Version:
An enterprise-class UI design language and Vue-based implementation
13 lines (11 loc) • 350 B
JavaScript
/*
* Finds element's position relative to the whole document,
* rather than to the viewport as it is the case with .getBoundingClientRect().
*/
export default function getElementPosition(element) {
const rect = element.getBoundingClientRect();
return {
top: rect.top + window.pageYOffset,
left: rect.left + window.pageXOffset,
};
}