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:
parent
f3f92ab425
commit
382c16a522
@ -70,8 +70,8 @@ function renderDocument(document, options, windowWidth, windowHeight) {
|
|||||||
var support = new Support(clonedWindow.document);
|
var support = new Support(clonedWindow.document);
|
||||||
var imageLoader = new ImageLoader(options, support);
|
var imageLoader = new ImageLoader(options, support);
|
||||||
var bounds = getBounds(node);
|
var bounds = getBounds(node);
|
||||||
var width = options.type === "view" ? Math.min(bounds.width, windowWidth) : documentWidth();
|
var width = options.type === "view" ? Math.min(bounds.width, windowWidth) : documentWidth(clonedWindow.document);
|
||||||
var height = options.type === "view" ? Math.min(bounds.height, windowHeight) : documentHeight();
|
var height = options.type === "view" ? Math.min(bounds.height, windowHeight) : documentHeight(clonedWindow.document);
|
||||||
var renderer = new CanvasRenderer(width, height, imageLoader);
|
var renderer = new CanvasRenderer(width, height, imageLoader);
|
||||||
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
||||||
return parser.ready.then(function() {
|
return parser.ready.then(function() {
|
||||||
@ -98,19 +98,19 @@ function crop(canvas, bounds) {
|
|||||||
return croppedCanvas;
|
return croppedCanvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
function documentWidth () {
|
function documentWidth (doc) {
|
||||||
return Math.max(
|
return Math.max(
|
||||||
Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
|
Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth),
|
||||||
Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
|
Math.max(doc.body.offsetWidth, doc.documentElement.offsetWidth),
|
||||||
Math.max(document.body.clientWidth, document.documentElement.clientWidth)
|
Math.max(doc.body.clientWidth, doc.documentElement.clientWidth)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function documentHeight () {
|
function documentHeight (doc) {
|
||||||
return Math.max(
|
return Math.max(
|
||||||
Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
|
Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight),
|
||||||
Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
|
Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight),
|
||||||
Math.max(document.body.clientHeight, document.documentElement.clientHeight)
|
Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,8 +259,6 @@ GradientContainer.prototype.TYPES = {
|
|||||||
RADIAL: 2
|
RADIAL: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
GradientContainer.prototype.angleRegExp = /([+-]?\d*\.?\d+)(deg|grad|rad|turn)/;
|
|
||||||
|
|
||||||
function ImageContainer(src, cors) {
|
function ImageContainer(src, cors) {
|
||||||
this.src = src;
|
this.src = src;
|
||||||
this.image = new Image();
|
this.image = new Image();
|
||||||
|
4
build/html2canvas.min.js
vendored
4
build/html2canvas.min.js
vendored
File diff suppressed because one or more lines are too long
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 support = new Support(clonedWindow.document);
|
||||||
var imageLoader = new ImageLoader(options, support);
|
var imageLoader = new ImageLoader(options, support);
|
||||||
var bounds = getBounds(node);
|
var bounds = getBounds(node);
|
||||||
var width = options.type === "view" ? Math.min(bounds.width, windowWidth) : documentWidth();
|
var width = options.type === "view" ? Math.min(bounds.width, windowWidth) : documentWidth(clonedWindow.document);
|
||||||
var height = options.type === "view" ? Math.min(bounds.height, windowHeight) : documentHeight();
|
var height = options.type === "view" ? Math.min(bounds.height, windowHeight) : documentHeight(clonedWindow.document);
|
||||||
var renderer = new CanvasRenderer(width, height, imageLoader);
|
var renderer = new CanvasRenderer(width, height, imageLoader);
|
||||||
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
||||||
return parser.ready.then(function() {
|
return parser.ready.then(function() {
|
||||||
@ -59,19 +59,19 @@ function crop(canvas, bounds) {
|
|||||||
return croppedCanvas;
|
return croppedCanvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
function documentWidth () {
|
function documentWidth (doc) {
|
||||||
return Math.max(
|
return Math.max(
|
||||||
Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
|
Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth),
|
||||||
Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
|
Math.max(doc.body.offsetWidth, doc.documentElement.offsetWidth),
|
||||||
Math.max(document.body.clientWidth, document.documentElement.clientWidth)
|
Math.max(doc.body.clientWidth, doc.documentElement.clientWidth)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function documentHeight () {
|
function documentHeight (doc) {
|
||||||
return Math.max(
|
return Math.max(
|
||||||
Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
|
Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight),
|
||||||
Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
|
Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight),
|
||||||
Math.max(document.body.clientHeight, document.documentElement.clientHeight)
|
Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user