mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-03 10:46:19 +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 getRect = node => {
|
||||||
const height = node.offsetHeight;
|
const height = node.offsetHeight;
|
||||||
const width = node.offsetWidth;
|
const width = node.offsetWidth;
|
||||||
let left = 0;
|
let left = node.offsetLeft;
|
||||||
let top = 0;
|
let top = node.offsetTop;
|
||||||
|
node = node.offsetParent;
|
||||||
|
|
||||||
while (node && node.nodeType === 1 /* Node.ELEMENT_NODE */) {
|
while (node && node.nodeType === 1 /* Node.ELEMENT_NODE */) {
|
||||||
left += node.offsetLeft;
|
left += node.offsetLeft - node.scrollLeft;
|
||||||
top += node.offsetTop;
|
top += node.offsetTop - node.scrollTop;
|
||||||
node = node.offsetParent;
|
node = node.offsetParent;
|
||||||
}
|
}
|
||||||
return { height, left, top, width };
|
return { height, left, top, width };
|
||||||
|
|||||||
Reference in New Issue
Block a user