summaryrefslogtreecommitdiff
path: root/ext/fg/js/document.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2019-10-20 11:23:20 -0700
committerAlex Yatskov <alex@foosoft.net>2019-10-20 11:23:20 -0700
commit438498435227cfa59cf9ed3430045b288cd2a7c0 (patch)
tree6a05520e5d6fa8d26d372673a9ed3e5d2da7e3fd /ext/fg/js/document.js
parent06d7713189be9eb51669d3842b78278371e6cfa4 (diff)
parentd32fd1381b6cd5141a21c22f9ef639b2fe9774fb (diff)
Merge branch 'master' into testing
Diffstat (limited to 'ext/fg/js/document.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;