Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reset of scroll positions #254

Closed
wants to merge 3 commits into from
Closed

Conversation

arrix
Copy link
Contributor

@arrix arrix commented Aug 6, 2013

by adding the page scroll offsets to the bounding rect.

@niklasvh
Copy link
Owner

niklasvh commented Aug 6, 2013

Global within html2canvas should be fine (everything within the script gets wrapped anyway). Caching does matter: http://jsperf.com/cache-scroll

@sjamaan
Copy link

sjamaan commented Jun 19, 2014

I would really like to see a fix like this.

I've been debugging for a full work day today only to find out that Android's Webview, like the piece of shit that it is, won't update the page.scrollYOffset upon window.scrollTo(). (the view is visually scrolled up, however!)

This means the scroll position is also not reflected in the calculations that are performed by getBoundingClientRect(), which means that if you take a "screenshot" of one HTML element while scrolled down, you'll end up with a canvas that "has its head chopped off". In other words, html2canvas thinks it's still scrolled down so it'll skip too many Y coordinates in the source canvas when copying the image to the destination canvas.

The horrible hacky workaround I have now is that I hook the scroll event using jQuery.one(), then scroll up. The event handler for the scroll event will call html2canvas. So far it looks like the event is consistently fired after the position has been updated.

@niklasvh
Copy link
Owner

This is fixed in 0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants