mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Fix rendering of content when window is scrolled
This commit is contained in:
10
src/core.js
10
src/core.js
@ -100,7 +100,7 @@ function renderWindow(node, container, options, windowWidth, windowHeight) {
|
||||
} else if (node === clonedWindow.document.body || node === clonedWindow.document.documentElement || options.canvas != null) {
|
||||
canvas = renderer.canvas;
|
||||
} else {
|
||||
canvas = crop(renderer.canvas, {width: options.width != null ? options.width : bounds.width, height: options.height != null ? options.height : bounds.height, top: bounds.top, left: bounds.left, x: clonedWindow.pageXOffset, y: clonedWindow.pageYOffset});
|
||||
canvas = crop(renderer.canvas, {width: options.width != null ? options.width : bounds.width, height: options.height != null ? options.height : bounds.height, top: bounds.top, left: bounds.left, x: 0, y: 0});
|
||||
}
|
||||
|
||||
cleanupContainer(container, options);
|
||||
@ -123,9 +123,11 @@ function crop(canvas, bounds) {
|
||||
var y2 = Math.min(canvas.height, Math.max(1, bounds.top + bounds.height));
|
||||
croppedCanvas.width = bounds.width;
|
||||
croppedCanvas.height = bounds.height;
|
||||
log("Cropping canvas at:", "left:", bounds.left, "top:", bounds.top, "width:", (x2-x1), "height:", (y2-y1));
|
||||
log("Resulting crop with width", bounds.width, "and height", bounds.height, " with x", x1, "and y", y1);
|
||||
croppedCanvas.getContext("2d").drawImage(canvas, x1, y1, x2-x1, y2-y1, bounds.x, bounds.y, x2-x1, y2-y1);
|
||||
var width = x2-x1;
|
||||
var height = y2-y1;
|
||||
log("Cropping canvas at:", "left:", bounds.left, "top:", bounds.top, "width:", width, "height:", height);
|
||||
log("Resulting crop with width", bounds.width, "and height", bounds.height, "with x", x1, "and y", y1);
|
||||
croppedCanvas.getContext("2d").drawImage(canvas, x1, y1, width, height, bounds.x, bounds.y, width, height);
|
||||
return croppedCanvas;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user