Skip to content

Commit 98804a6

Browse files
authored
Merge pull request #45 from GleapSDK/canvasScale
Fixed canvas when too big
2 parents ca1d4d4 + 118e10c commit 98804a6

File tree

7 files changed

+23
-72
lines changed

7 files changed

+23
-72
lines changed

build/cjs/index.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.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

demo/index.html

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -259,36 +259,7 @@ <h2 class="sub-headline">
259259
<div class="header-container-image">
260260
<img class="head-image" src="./pexels-niklas-jeromin-12734294.jpg" />
261261
</div>
262-
<canvas id="myCanvas" width="200" height="200" style="border:1px solid #000000;"></canvas>
263-
264-
<script>
265-
var canvas = document.getElementById('myCanvas');
266-
var ctx = canvas.getContext('2d');
267-
var centerX = canvas.width / 2;
268-
var centerY = canvas.height / 2;
269-
var radius = 70;
270-
271-
ctx.beginPath();
272-
ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
273-
ctx.fillStyle = 'blue';
274-
ctx.fill();
275-
ctx.stroke();
276-
</script>
277-
278-
<!-- The Modal -->
279-
<div id="myModal" class="modal">
280-
281-
<!-- Modal content -->
282-
<div class="modal-content">
283-
<span class="close">&times;</span>
284-
<p>Some text in the Modal..</p>
285-
</div>
286-
287-
</div>
288-
289262
<div class="content" id="haha">
290-
<button id="myBtn222">Open Modal</button>
291-
<a href="https://www.google.com">asdf asfasdfasfdasdf</a>
292263
<div class="skeleton-text"></div>
293264
<div class="skeleton-text"></div>
294265
<div class="skeleton-text"></div>
@@ -297,35 +268,6 @@ <h2 class="sub-headline">
297268
<div class="skeleton-text"></div>
298269
<div class="skeleton-text"></div>
299270
</div>
300-
301-
<script>
302-
// Get the modal
303-
var modal = document.getElementById("myModal");
304-
305-
// Get the button that opens the modal
306-
var btn = document.getElementById("myBtn");
307-
308-
// Get the <span> element that closes the modal
309-
var span = document.getElementsByClassName("close")[0];
310-
311-
// When the user clicks the button, open the modal
312-
btn.onclick = function () {
313-
modal.style.display = "block";
314-
}
315-
316-
// When the user clicks on <span> (x), close the modal
317-
span.onclick = function () {
318-
modal.style.display = "none";
319-
}
320-
321-
// When the user clicks anywhere outside of the modal, close it
322-
window.onclick = function (event) {
323-
if (event.target == modal) {
324-
modal.style.display = "none";
325-
}
326-
}
327-
328-
</script>
329271
</body>
330272

331273
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "13.7.6",
3+
"version": "13.7.7",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/13.7.7/index.js

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

published/latest/index.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/ScreenCapture.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const replaceStyleNodes = (clone, styleSheet, cssTextContent, styleId) => {
212212
cloneTargetNode.remove();
213213
}
214214
}
215-
} catch (exp) { }
215+
} catch (exp) {}
216216
}
217217
};
218218

@@ -224,7 +224,7 @@ const getTextContentFromStyleSheet = (styleSheet) => {
224224
} else if (styleSheet.rules) {
225225
cssRules = styleSheet.rules;
226226
}
227-
} catch (exp) { }
227+
} catch (exp) {}
228228

229229
var cssTextContent = "";
230230
if (cssRules) {
@@ -236,15 +236,15 @@ const getTextContentFromStyleSheet = (styleSheet) => {
236236
}
237237

238238
return cssTextContent;
239-
}
239+
};
240240

241241
const downloadAllCSSUrlResources = (clone, remote) => {
242242
var promises = [];
243243
for (var i = 0; i < document.styleSheets.length; i++) {
244244
const styleSheet = document.styleSheets[i];
245245

246246
// Skip if the stylesheet is meant for print
247-
if (styleSheet.media && styleSheet.media.mediaText === 'print') {
247+
if (styleSheet.media && styleSheet.media.mediaText === "print") {
248248
continue;
249249
}
250250

@@ -349,12 +349,12 @@ const handleAdoptedStyleSheets = (doc, clone, shadowNodeId) => {
349349
clone.insertBefore(shadowStyleNode, clone.firstElementChild);
350350
}
351351
}
352-
}
352+
};
353353

354354
const deepClone = (host) => {
355355
let shadowNodeId = 1;
356356

357-
const cloneNode = (node, parent, shadowRoot) => {
357+
const cloneNode = async (node, parent, shadowRoot) => {
358358
const walkTree = (nextn, nextp, innerShadowRoot) => {
359359
while (nextn) {
360360
cloneNode(nextn, nextp, innerShadowRoot);
@@ -371,7 +371,12 @@ const deepClone = (host) => {
371371

372372
if (node instanceof HTMLCanvasElement) {
373373
try {
374-
clone.setAttribute("bb-canvas-data", resizeImage(node.toDataURL(), 750, 750));
374+
const boundingRect = node.getBoundingClientRect();
375+
const resizedImage = await resizeImage(node.toDataURL(), 900, 900);
376+
377+
clone.setAttribute("bb-canvas-data", resizedImage);
378+
clone.setAttribute("bb-canvas-height", boundingRect.height);
379+
clone.setAttribute("bb-canvas-width", boundingRect.width);
375380
} catch (exp) {
376381
console.warn("Gleap: Failed to clone canvas data.", exp);
377382
}
@@ -393,7 +398,7 @@ const deepClone = (host) => {
393398
clone.setAttribute("bb-width", boundingRect.width);
394399
}
395400

396-
if ((node.scrollTop > 0 || node.scrollLeft > 0)) {
401+
if (node.scrollTop > 0 || node.scrollLeft > 0) {
397402
clone.setAttribute("bb-scrollpos", true);
398403
clone.setAttribute("bb-scrolltop", node.scrollTop);
399404
clone.setAttribute("bb-scrollleft", node.scrollLeft);
@@ -407,7 +412,7 @@ const deepClone = (host) => {
407412
var val = node.value;
408413
if (
409414
node.getAttribute("gleap-ignore") === "value" ||
410-
node.classList.contains('gl-mask')
415+
node.classList.contains("gl-mask")
411416
) {
412417
val = new Array(val.length + 1).join("*");
413418
}
@@ -494,7 +499,10 @@ const prepareScreenshotData = (remote) => {
494499
}
495500

496501
// Adjust the base node
497-
const baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("/"));
502+
const baseUrl = window.location.href.substring(
503+
0,
504+
window.location.href.lastIndexOf("/")
505+
);
498506
var newBaseUrl = baseUrl + "/";
499507
if (existingBasePath) {
500508
if (existingBasePath.startsWith("http")) {

0 commit comments

Comments
 (0)