mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-08-15 18:45:06 +00:00
[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:
committed by
Nicolas Gallagher
parent
2a4d1c81d8
commit
b793737393
@@ -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 };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user