[Flare] More fixes for getAbsoluteBoundingClientRect (#15746)

This commit is contained in:
Dominic Gannaway
2019-05-27 19:03:40 +01:00
committed by GitHub
parent 5fe97dbe19
commit a97b5c07b0
2 changed files with 12 additions and 7 deletions
+11 -6
View File
@@ -459,12 +459,17 @@ function getAbsoluteBoundingClientRect(
// are fixed position, using offsetParent node for a fast-path.
// We need to check both as offsetParent accounts for both
// itself and the parent; so we need to align with that API.
// If these all pass, we can stop traversing the tree.
if (
(scrollLeft !== 0 || scrollTop !== 0) &&
(isNodeFixedPositioned(parent) || isNodeFixedPositioned(node))
) {
break;
// If these all pass, we can skip traversing the relevant
// node and go directly to its parent.
if (scrollLeft !== 0 || scrollTop !== 0) {
if (isNodeFixedPositioned(parent)) {
node = ((parent: any): Node).parentNode;
continue;
}
if (isNodeFixedPositioned(node)) {
node = parent;
continue;
}
}
offsetX += scrollLeft;
offsetY += scrollTop;
@@ -1232,7 +1232,7 @@ describe('Event responder: Press', () => {
document.firstElementChild.scrollTop = 1000;
const updatedCoordinatesInside = {
pageX: coordinatesInside.pageX,
pageY: coordinatesInside.pageY + 100,
pageY: coordinatesInside.pageY + 1100,
};
ref.current.dispatchEvent(
createEvent('pointerdown', updatedCoordinatesInside),