[fix] onLayout calculation

The 0.0.69 release introduced a regression in UIManager's measurement
calculations.

Using `offset` properties returns the offset relative to the closest
positioned ancestor. Make `getRect` iterate over the ancestor chain.

Fix #341
Close #345
This commit is contained in:
Matthias Le Brun
2017-02-05 12:09:42 -08:00
committed by Nicolas Gallagher
parent 2a4d1c81d8
commit b793737393
+7 -2
View File
@@ -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 };
};