mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Correctly crop content
This commit is contained in:
10
src/core.js
10
src/core.js
@ -40,11 +40,19 @@ function renderDocument(document, options, windowWidth, windowHeight) {
|
||||
if (options.removeContainer) {
|
||||
container.parentNode.removeChild(container);
|
||||
}
|
||||
return renderer.canvas;
|
||||
return (options.type !== "view" && (node === clonedWindow.document.body || node === clonedWindow.document.documentElement)) ? renderer.canvas : crop(renderer.canvas, bounds);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function crop(canvas, bounds) {
|
||||
var croppedCanvas = document.createElement("canvas");
|
||||
croppedCanvas.width = bounds.width;
|
||||
croppedCanvas.height = bounds.height;
|
||||
croppedCanvas.getContext("2d").drawImage(canvas, bounds.left, bounds.top, bounds.width, bounds.height, 0, 0, bounds.width, bounds.height);
|
||||
return croppedCanvas;
|
||||
}
|
||||
|
||||
function documentWidth () {
|
||||
return Math.max(
|
||||
Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
|
||||
|
Reference in New Issue
Block a user