mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
use cloned document for measurements
This commit is contained in:
20
src/core.js
20
src/core.js
@ -31,8 +31,8 @@ function renderDocument(document, options, windowWidth, windowHeight) {
|
||||
var support = new Support(clonedWindow.document);
|
||||
var imageLoader = new ImageLoader(options, support);
|
||||
var bounds = getBounds(node);
|
||||
var width = options.type === "view" ? Math.min(bounds.width, windowWidth) : documentWidth();
|
||||
var height = options.type === "view" ? Math.min(bounds.height, windowHeight) : documentHeight();
|
||||
var width = options.type === "view" ? Math.min(bounds.width, windowWidth) : documentWidth(clonedWindow.document);
|
||||
var height = options.type === "view" ? Math.min(bounds.height, windowHeight) : documentHeight(clonedWindow.document);
|
||||
var renderer = new CanvasRenderer(width, height, imageLoader);
|
||||
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
||||
return parser.ready.then(function() {
|
||||
@ -59,19 +59,19 @@ function crop(canvas, bounds) {
|
||||
return croppedCanvas;
|
||||
}
|
||||
|
||||
function documentWidth () {
|
||||
function documentWidth (doc) {
|
||||
return Math.max(
|
||||
Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
|
||||
Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
|
||||
Math.max(document.body.clientWidth, document.documentElement.clientWidth)
|
||||
Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth),
|
||||
Math.max(doc.body.offsetWidth, doc.documentElement.offsetWidth),
|
||||
Math.max(doc.body.clientWidth, doc.documentElement.clientWidth)
|
||||
);
|
||||
}
|
||||
|
||||
function documentHeight () {
|
||||
function documentHeight (doc) {
|
||||
return Math.max(
|
||||
Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
|
||||
Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
|
||||
Math.max(document.body.clientHeight, document.documentElement.clientHeight)
|
||||
Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight),
|
||||
Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight),
|
||||
Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user