Skip to content

Commit 636eb04

Browse files
authored
Merge pull request #217 from SarahG-579462/main
Fix scrollbar flickering
2 parents ca6ff28 + 5cbd356 commit 636eb04

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/dom-to-image-more.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
const inliner = newInliner();
66
const fontFaces = newFontFaces();
77
const images = newImages();
8-
8+
const offscreen = {
9+
position: 'fixed',
10+
left: '-9999px',
11+
visibility: 'hidden',
12+
};
913
// Default impl options
1014
const defaultOptions = {
1115
// Default is to copy default styles of elements
@@ -782,6 +786,7 @@
782786
const base = doc.createElement('base');
783787
doc.head.appendChild(base);
784788
const a = doc.createElement('a');
789+
a.style = offscreen;
785790
doc.body.appendChild(a);
786791
base.href = baseUrl;
787792
a.href = url;
@@ -839,6 +844,7 @@
839844
};
840845

841846
svg.appendChild(image);
847+
svg.style = { ...svg.style, ...offscreen };
842848
image.src = uri;
843849

844850
// Add the SVG to the document body (invisible)
@@ -1472,8 +1478,7 @@
14721478
// render at all with `display: none`, so we have to use `visibility: hidden` with `position: fixed`.
14731479
sandbox = document.createElement('iframe');
14741480
sandbox.id = 'domtoimage-sandbox-' + util.uid();
1475-
sandbox.style.visibility = 'hidden';
1476-
sandbox.style.position = 'fixed';
1481+
sandbox.style = offscreen;
14771482
document.body.appendChild(sandbox);
14781483

14791484
return tryTechniques(

0 commit comments

Comments
 (0)