Skip to content

Commit

Permalink
[fix] NativeMethodsMixin measure/measureInWindow with scroll
Browse files Browse the repository at this point in the history
Account for scroll offsets when calculating measurements.

Fix #702
Fix #805
Close #806
  • Loading branch information
kidasovmercury authored and necolas committed Feb 12, 2018
1 parent 9ee89bc commit 399f465
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/react-native-web/src/exports/UIManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import setValueForStyles from '../../vendor/setValueForStyles';
const getRect = node => {
const height = node.offsetHeight;
const width = node.offsetWidth;
let left = 0;
let top = 0;
let left = node.offsetLeft;
let top = node.offsetTop;
node = node.offsetParent;

while (node && node.nodeType === 1 /* Node.ELEMENT_NODE */) {
left += node.offsetLeft;
top += node.offsetTop;
left += node.offsetLeft - node.scrollLeft;
top += node.offsetTop - node.scrollTop;
node = node.offsetParent;
}
return { height, left, top, width };
Expand Down

0 comments on commit 399f465

Please sign in to comment.