Skip to content

Commit

Permalink
fix: US157225 - Ignore base element rects that throw off the position…
Browse files Browse the repository at this point in the history
…ing because they have no width and/or height (#162)
  • Loading branch information
svanherk authored Sep 5, 2023
1 parent 17f38ab commit 22ca908
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/browser/vdiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ function findLargestRect(elems) {
const targets = findTargets(elem);
targets.forEach(target => {
const targetRect = target.getBoundingClientRect();
largestRect = {
left: Math.floor(Math.min(largestRect.left, targetRect.left)),
top: Math.floor(Math.min(largestRect.top, targetRect.top)),
right: Math.ceil(Math.max(largestRect.right, targetRect.right)),
bottom: Math.ceil(Math.max(largestRect.bottom, targetRect.bottom))
};
if (targetRect.width !== 0 && targetRect.height !== 0) {
largestRect = {
left: Math.floor(Math.min(largestRect.left, targetRect.left)),
top: Math.floor(Math.min(largestRect.top, targetRect.top)),
right: Math.ceil(Math.max(largestRect.right, targetRect.right)),
bottom: Math.ceil(Math.max(largestRect.bottom, targetRect.bottom))
};
}
});
});

Expand Down

0 comments on commit 22ca908

Please sign in to comment.