Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3972 from chenba/3907-selection-shift
Browse files Browse the repository at this point in the history
Negate body shift in scroll-proof fashion.
  • Loading branch information
ianb authored Jan 16, 2018
2 parents 1ace4b1 + 8fd35ef commit 5e71495
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions addon/webextension/selector/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,10 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
// document's body is not at (0, 0) of the viewport. That makes the
// frame shifted relative to the viewport. These margins negates that.
if (window.getComputedStyle(document.body).position === "relative") {
let boundingRect = document.body.getBoundingClientRect();
if (boundingRect.x) {
this.element.style.marginLeft = `-${boundingRect.x}px`;
}
if (boundingRect.y) {
this.element.style.marginTop = `-${boundingRect.y}px`;
}
let docBoundingRect = document.documentElement.getBoundingClientRect();
let bodyBoundingRect = document.body.getBoundingClientRect();
this.element.style.marginLeft = `-${bodyBoundingRect.right - docBoundingRect.right}px`;
this.element.style.marginTop = `-${bodyBoundingRect.bottom - docBoundingRect.bottom}px`;
}
}
if (force && visible) {
Expand Down

0 comments on commit 5e71495

Please # to comment.