Skip to content

Commit fa659ad

Browse files
committed
Fix background-size with background-repeat x and y as well (niklasvh#447)
1 parent f517a35 commit fa659ad

4 files changed

Lines changed: 31 additions & 29 deletions

File tree

dist/html2canvas.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,20 +2369,20 @@ Renderer.prototype.renderBackgroundRepeating = function(container, bounds, image
23692369
var position = container.parseBackgroundPosition(bounds, imageContainer.image, index, size);
23702370
var repeat = container.parseBackgroundRepeat(index);
23712371
switch (repeat) {
2372-
case "repeat-x":
2373-
case "repeat no-repeat":
2374-
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + borderData[3], bounds.top + position.top + borderData[0], 99999, imageContainer.image.height, borderData);
2375-
break;
2376-
case "repeat-y":
2377-
case "no-repeat repeat":
2378-
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + borderData[0], imageContainer.image.width, 99999, borderData);
2379-
break;
2380-
case "no-repeat":
2381-
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + position.top + borderData[0], size.width, size.height, borderData);
2382-
break;
2383-
default:
2384-
this.renderBackgroundRepeat(imageContainer, position, size, {top: bounds.top, left: bounds.left}, borderData[3], borderData[0]);
2385-
break;
2372+
case "repeat-x":
2373+
case "repeat no-repeat":
2374+
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + borderData[3], bounds.top + position.top + borderData[0], 99999, size.height, borderData);
2375+
break;
2376+
case "repeat-y":
2377+
case "no-repeat repeat":
2378+
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + borderData[0], size.width, 99999, borderData);
2379+
break;
2380+
case "no-repeat":
2381+
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + position.top + borderData[0], size.width, size.height, borderData);
2382+
break;
2383+
default:
2384+
this.renderBackgroundRepeat(imageContainer, position, size, {top: bounds.top, left: bounds.left}, borderData[3], borderData[0]);
2385+
break;
23862386
}
23872387
};
23882388

dist/html2canvas.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ Renderer.prototype.renderBackgroundRepeating = function(container, bounds, image
8686
var position = container.parseBackgroundPosition(bounds, imageContainer.image, index, size);
8787
var repeat = container.parseBackgroundRepeat(index);
8888
switch (repeat) {
89-
case "repeat-x":
90-
case "repeat no-repeat":
91-
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + borderData[3], bounds.top + position.top + borderData[0], 99999, imageContainer.image.height, borderData);
92-
break;
93-
case "repeat-y":
94-
case "no-repeat repeat":
95-
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + borderData[0], imageContainer.image.width, 99999, borderData);
96-
break;
97-
case "no-repeat":
98-
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + position.top + borderData[0], size.width, size.height, borderData);
99-
break;
100-
default:
101-
this.renderBackgroundRepeat(imageContainer, position, size, {top: bounds.top, left: bounds.left}, borderData[3], borderData[0]);
102-
break;
89+
case "repeat-x":
90+
case "repeat no-repeat":
91+
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + borderData[3], bounds.top + position.top + borderData[0], 99999, size.height, borderData);
92+
break;
93+
case "repeat-y":
94+
case "no-repeat repeat":
95+
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + borderData[0], size.width, 99999, borderData);
96+
break;
97+
case "no-repeat":
98+
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + position.top + borderData[0], size.width, size.height, borderData);
99+
break;
100+
default:
101+
this.renderBackgroundRepeat(imageContainer, position, size, {top: bounds.top, left: bounds.left}, borderData[3], borderData[0]);
102+
break;
103103
}
104104
};
105105

tests/cases/background/size.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
</head>
4141
<body>
4242
<div class="container"></div>
43+
<div class="container" style="background-repeat: repeat-y"></div>
44+
<div class="container" style="background-repeat: repeat-x"></div>
4345

4446
<div class="horizontal">
4547
<div style='background-size: cover;'></div>

0 commit comments

Comments
 (0)