aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-17 19:30:54 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-17 19:30:54 -0400
commita5d7de8e97400f63c328ccde9b313a127cef0611 (patch)
tree6a5daabfcd9d9f554035ecb9554e6290d68aed4d /ext/fg/js
parent8f918c63dcf82bfcdba47100194b34e4be2dd531 (diff)
Add correction to offset of imposter rect
Necessary when dealing with CSS transforms
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/document.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index 94a68e6c..a168705e 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -27,8 +27,8 @@ function docImposterCreate(element, isTextarea) {
const elementStyle = window.getComputedStyle(element);
const elementRect = element.getBoundingClientRect();
const documentRect = document.documentElement.getBoundingClientRect();
- const left = elementRect.left - documentRect.left;
- const top = elementRect.top - documentRect.top;
+ let left = elementRect.left - documentRect.left;
+ let top = elementRect.top - documentRect.top;
// Container
const container = document.createElement('div');
@@ -82,6 +82,12 @@ function docImposterCreate(element, isTextarea) {
docSetImposterStyle(imposterStyle, 'width', `${width}px`);
docSetImposterStyle(imposterStyle, 'height', `${height}px`);
}
+ if (imposterRect.x !== elementRect.x || imposterRect.y !== elementRect.y) {
+ left += (elementRect.left - imposterRect.left);
+ top += (elementRect.top - imposterRect.top);
+ docSetImposterStyle(imposterStyle, 'left', `${left}px`);
+ docSetImposterStyle(imposterStyle, 'top', `${top}px`);
+ }
imposter.scrollTop = element.scrollTop;
imposter.scrollLeft = element.scrollLeft;