question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:46
  • Comments:50

github_iconTop GitHub Comments

144reactions
GerardoFurtadocommented, Jul 16, 2019

I was facing the same problem, but setting scrollY: 0 didn’t fix it. I ended up fixing it by reversing the vertical scroll with window.scrollY, like this:

{
    scrollX: 0,
    scrollY: -window.scrollY
}

As this is quite a hack it would be really great having this issue fixed! Cheers 🍻

50reactions
GerkinDevcommented, Jul 9, 2019

Hey people ! I had the same problem, but I managed to fix it using explicit scrollX & scrollY options, set to 0. See http://html2canvas.hertzen.com/configuration/

Cheers ! 🍻

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found