diff --git a/src/apis/UIManager/index.js b/src/apis/UIManager/index.js index 6622cdef..2a397d89 100644 --- a/src/apis/UIManager/index.js +++ b/src/apis/UIManager/index.js @@ -3,9 +3,14 @@ import CSSPropertyOperations from 'react-dom/lib/CSSPropertyOperations'; const getRect = (node) => { const height = node.offsetHeight; - const left = node.offsetLeft; - const top = node.offsetTop; const width = node.offsetWidth; + let left = 0; + let top = 0; + while (node && node.nodeType === 1 /* Node.ELEMENT_NODE */) { + left += node.offsetLeft; + top += node.offsetTop; + node = node.offsetParent; + } return { height, left, top, width }; };