Canvas rendered with a big blank offset if I scroll to the bottom of the captured element
See original GitHub issue- You are using the latest version
- You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console
Bug reports:
In 1.0.0-rc.3 If I scroll to the top of the page (where the element starts), it works perfectly. Wrong: https://ibb.co/8Y9SnTV (scrolling to the bottom of the element) Good: https://ibb.co/7z1903r (scrolling to the top of the element)
window.scrollTo(0, 0); // <-- this fixes the issue
html2canvas(document.getElementById('drag-container-outer')).then((canvas) => {
var a = document.createElement('a');
a.href = canvas.toDataURL('image/jpeg');
a.download = 'somefile.jpg';
a.click();
});
In 1.0.0-rc.1 Works perfectly, there is no need to scroll.
Specifications:
- html2canvas version tested with: — wrong: v1.0.0-rc.3 | good: 1.0.0-rc.1
- Browser & version: Chrome 75.0.3770.80
- Operating system: Windows
Issue Analytics
- State:
- Created 4 years ago
- Reactions:46
- Comments:50
Top Results From Across the Web
HTML2Canvas does not render full div, only what is visible on ...
If I scroll to the very top of the page then run the script it will render the entire div as it should....
Read more >overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >Button | Android Developers
android:hint, Hint text to display when the text is empty. ... The content of this view will be considered for scroll capture if...
Read more >html-to-image - npm
Generates an image from a DOM node using HTML5 canvas and SVG. ... Defaults to an empty string and will render empty areas...
Read more >Scroll Events and Intersection Observer - Beginner JavaScript
That is where the user is forced to scroll all the way to the bottom of the ... If it's the case of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was facing the same problem, but setting
scrollY: 0
didn’t fix it. I ended up fixing it by reversing the vertical scroll withwindow.scrollY
, like this:As this is quite a hack it would be really great having this issue fixed! Cheers 🍻
Hey people ! I had the same problem, but I managed to fix it using explicit
scrollX
&scrollY
options, set to0
. See http://html2canvas.hertzen.com/configuration/Cheers ! 🍻