mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Don't scroll owner document after cloned document load
This commit is contained in:
parent
1e826e32ae
commit
069140974b
7
dist/html2canvas.js
vendored
7
dist/html2canvas.js
vendored
@ -694,8 +694,10 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
|
|||||||
|
|
||||||
container.className = "html2canvas-container";
|
container.className = "html2canvas-container";
|
||||||
container.style.visibility = "hidden";
|
container.style.visibility = "hidden";
|
||||||
container.style.position = "absolute";
|
container.style.position = "fixed";
|
||||||
container.style.left = container.style.top = "-10000px";
|
container.style.left = "-10000px";
|
||||||
|
container.style.top = "0px";
|
||||||
|
container.style.border = "0";
|
||||||
container.width = width;
|
container.width = width;
|
||||||
container.height = height;
|
container.height = height;
|
||||||
container.scrolling = "no"; // ios won't scroll without it
|
container.scrolling = "no"; // ios won't scroll without it
|
||||||
@ -712,7 +714,6 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
|
|||||||
cloneCanvasContents(ownerDocument, documentClone);
|
cloneCanvasContents(ownerDocument, documentClone);
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
if (options.type === "view") {
|
if (options.type === "view") {
|
||||||
restoreOwnerScroll(ownerDocument, x, y);
|
|
||||||
container.contentWindow.scrollTo(x, y);
|
container.contentWindow.scrollTo(x, y);
|
||||||
}
|
}
|
||||||
resolve(container);
|
resolve(container);
|
||||||
|
2
dist/html2canvas.min.js
vendored
2
dist/html2canvas.min.js
vendored
File diff suppressed because one or more lines are too long
@ -126,8 +126,10 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
|
|||||||
|
|
||||||
container.className = "html2canvas-container";
|
container.className = "html2canvas-container";
|
||||||
container.style.visibility = "hidden";
|
container.style.visibility = "hidden";
|
||||||
container.style.position = "absolute";
|
container.style.position = "fixed";
|
||||||
container.style.left = container.style.top = "-10000px";
|
container.style.left = "-10000px";
|
||||||
|
container.style.top = "0px";
|
||||||
|
container.style.border = "0";
|
||||||
container.width = width;
|
container.width = width;
|
||||||
container.height = height;
|
container.height = height;
|
||||||
container.scrolling = "no"; // ios won't scroll without it
|
container.scrolling = "no"; // ios won't scroll without it
|
||||||
@ -144,7 +146,6 @@ function createWindowClone(ownerDocument, containerDocument, width, height, opti
|
|||||||
cloneCanvasContents(ownerDocument, documentClone);
|
cloneCanvasContents(ownerDocument, documentClone);
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
if (options.type === "view") {
|
if (options.type === "view") {
|
||||||
restoreOwnerScroll(ownerDocument, x, y);
|
|
||||||
container.contentWindow.scrollTo(x, y);
|
container.contentWindow.scrollTo(x, y);
|
||||||
}
|
}
|
||||||
resolve(container);
|
resolve(container);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="mocha"></div>
|
<div id="mocha"></div>
|
||||||
<script>mocha.setup('bdd')</script>
|
<script>mocha.setup('bdd')</script>
|
||||||
<div style="height: 2100px;"></div>
|
<div style="height: 2200px;"></div>
|
||||||
<div style="height: 500px;background: green;"><a name="content">content</a></div>
|
<div style="height: 500px;background: green;"><a name="content">content</a></div>
|
||||||
<script>
|
<script>
|
||||||
describe("Scrolling", function() {
|
describe("Scrolling", function() {
|
||||||
@ -32,10 +32,10 @@
|
|||||||
window.location.hash = "#content";
|
window.location.hash = "#content";
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var top = $(window).scrollTop();
|
var top = $(window).scrollTop();
|
||||||
html2canvas(document.body, {type: 'view', logging: true}).then(function (canvas) {
|
html2canvas(document.body, {type: 'view', logging: true, removeContainer: false}).then(function () {
|
||||||
var currentTop = $(window).scrollTop();
|
var currentTop = $(window).scrollTop();
|
||||||
window.location.hash = "";
|
window.location.hash = "";
|
||||||
expect(currentTop).to.be.greaterThan(2000);
|
expect(currentTop).to.be.greaterThan(1500);
|
||||||
expect(currentTop).to.equal(top);
|
expect(currentTop).to.equal(top);
|
||||||
done();
|
done();
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user