Skip to content

Commit

Permalink
Merge pull request #1 from soandrew/master
Browse files Browse the repository at this point in the history
Fix extra whitespace in generated image when scrollbar is present
  • Loading branch information
mhuap authored Feb 27, 2020
2 parents 93f7321 + 61fac3c commit ccaf05a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class Result extends React.Component {

genCanvas(){
const html2canvas = require('html2canvas');
window.scrollTo(0,0)
window.scrollTo(0,0);

// Hide scrollbar to fix bug with html2canvas which adds extra whitespace to image if scrollbar is present
document.documentElement.style.overflow = 'hidden';

html2canvas(document.querySelector("#preview .tweet-container"), {allowTaint: true, useCORS: true})
.then((canvas) => {

Expand All @@ -53,6 +57,9 @@ class Result extends React.Component {
}
});

// Un-hide scrollbar
document.documentElement.style.overflow = '';

scroller.scrollTo('canvas')

}
Expand Down

0 comments on commit ccaf05a

Please sign in to comment.