1
1
/**
2
- * Copyright © Magento, Inc. All rights reserved.
3
- * See COPYING.txt for license details .
2
+ * Copyright 2019 Adobe
3
+ * All Rights Reserved .
4
4
*/
5
5
6
6
import html2canvas from "html2canvas" ;
@@ -138,6 +138,7 @@ function createCapture(stage: Stage) {
138
138
renderingLock . then ( ( ) => {
139
139
// Resolve issues with Parallax
140
140
const parallaxRestore = disableParallax ( stageElement ) ;
141
+ const canvasElement = document . querySelector ( "#" + stage . id + " .pagebuilder-canvas" ) as HTMLElement ;
141
142
142
143
stageElement . style . height = $ ( stageElement ) . outerHeight ( false ) + "px" ;
143
144
stageElement . classList . add ( "capture" ) ;
@@ -151,11 +152,12 @@ function createCapture(stage: Stage) {
151
152
152
153
_ . defer ( ( ) => {
153
154
html2canvas (
154
- document . querySelector ( "#" + stage . id + " .pagebuilder-canvas" ) ,
155
+ canvasElement ,
155
156
{
156
157
scale : 1 ,
157
158
useCORS : true ,
158
159
scrollY : ( window . pageYOffset * - 1 ) ,
160
+ height : correctCanvasHeight ( canvasElement ) ,
159
161
} ,
160
162
) . then ( ( canvas : HTMLCanvasElement ) => {
161
163
const imageSrc = canvas . toDataURL ( "image/jpeg" , 0.85 ) ;
@@ -216,6 +218,16 @@ function restoreParallax(rows: ResetRowInterface[]) {
216
218
} ) ;
217
219
}
218
220
221
+ /**
222
+ * Adjust canvas element size to prevent area overflow.
223
+ *
224
+ * @param canvasElement
225
+ */
226
+ function correctCanvasHeight ( canvasElement : HTMLElement ) {
227
+ // @ts -ignore
228
+ return canvasElement . getHeight ( ) < 4096 ? canvasElement . getHeight ( ) : 4096 ;
229
+ }
230
+
219
231
interface ResetRowInterface {
220
232
element : HTMLElement ;
221
233
styles : string ;
0 commit comments