mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Use correct document context for canvas render
This commit is contained in:
@ -36,7 +36,7 @@ function renderDocument(document, options, windowWidth, windowHeight) {
|
||||
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 renderer = new CanvasRenderer(width, height, imageLoader, options);
|
||||
var renderer = new CanvasRenderer(width, height, imageLoader, options, document);
|
||||
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
||||
return parser.ready.then(function() {
|
||||
log("Finished rendering");
|
||||
|
@ -1,8 +1,9 @@
|
||||
function Renderer(width, height, images, options) {
|
||||
function Renderer(width, height, images, options, document) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.images = images;
|
||||
this.options = options;
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
Renderer.prototype.renderImage = function(container, bounds, borderData, imageContainer) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
function CanvasRenderer(width, height) {
|
||||
Renderer.apply(this, arguments);
|
||||
this.canvas = document.createElement("canvas");
|
||||
this.canvas = this.document.createElement("canvas");
|
||||
this.canvas.width = width;
|
||||
this.canvas.height = height;
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
this.taintCtx = document.createElement("canvas").getContext("2d");
|
||||
this.taintCtx = this.document.createElement("canvas").getContext("2d");
|
||||
this.ctx.textBaseline = "bottom";
|
||||
this.variables = {};
|
||||
log("Initialized CanvasRenderer");
|
||||
|
Reference in New Issue
Block a user