mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-25 23:48:54 +00:00
[fix] NativeMethodsMixin measure/measureInWindow with scroll
Account for scroll offsets when calculating measurements. Fix #702 Fix #805 Close #806
This commit is contained in:
committed by
Nicolas Gallagher
parent
9ee89bc7f7
commit
399f465e59
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user