Skip to content

Commit 92bff8a

Browse files
committed
draggable recording bar
1 parent 897c9b8 commit 92bff8a

File tree

8 files changed

+122
-11
lines changed

8 files changed

+122
-11
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/main.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,34 @@ Gleap.setFrameUrl("http://0.0.0.0:3001");
44
Gleap.setApiUrl("http://0.0.0.0:9000");
55
Gleap.setWSApiUrl("ws://0.0.0.0:9000");
66

7-
Gleap.initialize("BTmQRJBPvKrOErNQCmyPYPAzSsw3gPmw");
7+
// Gleap.setLanguage("en");
88

9-
Gleap.registerCustomAction((customAction) => {
10-
console.log(customAction);
11-
});
9+
Gleap.initialize("VHKvTzWV8jKjms6mWWygiUDWlL8zs7an");
1210

13-
Gleap.setTicketAttribute("test", "test");
11+
// const lastMonthDate = new Date();
12+
// lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
1413

15-
Gleap.unsetTicketAttribute("test");
14+
Gleap.identify("94383829393", {
15+
email: "luca@gleap.io",
16+
name: "Luca Blaser",
17+
})
1618

17-
Gleap.clearTicketAttributes();
19+
Gleap.open();
20+
21+
// Gleap.showSurvey("c01abef016b8efb03a9a", "survey_full");
22+
23+
24+
// Gleap.startChecklist("677694a38779ab927064d967");
25+
26+
// Gleap.trackEvent("Add New List");
27+
// Gleap.trackEvent("Step 2 resolved");
28+
// Gleap.trackEvent("Step 3 resolved");
29+
30+
// setTimeout(() => {
31+
// Gleap.trackEvent("Step 4 resolved");
32+
// }, 4000);
33+
// Gleap.setTicketAttribute("qwerrewq", "Custom value")
34+
// Gleap.attachCustomData({
35+
// test: "dataaa",
36+
// })
37+
// Gleap.startBot("6789110e41e9869af7a2b6b8")

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": "14.2.1",
3+
"version": "14.2.2",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/14.2.2/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/GleapMarkerManager.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ export default class GleapMarkerManager {
164164
this.touchMoveEventHandler
165165
);
166166

167+
// Clean up toolbar drag listeners
168+
const dragHandle = document.querySelector(".bb-capture-toolbar-item[data-type='drag']");
169+
if (dragHandle) {
170+
dragHandle.removeEventListener("mousedown", this.dragStart);
171+
dragHandle.removeEventListener("touchstart", this.dragStart);
172+
document.removeEventListener("mousemove", this.drag);
173+
document.removeEventListener("touchmove", this.drag);
174+
document.removeEventListener("mouseup", this.dragEnd);
175+
document.removeEventListener("touchend", this.dragEnd);
176+
}
177+
167178
if (this.dragCursor) {
168179
this.dragCursor.remove();
169180
}
@@ -179,6 +190,9 @@ export default class GleapMarkerManager {
179190
<div class="bb-capture-dismiss">${loadIcon("dismiss")}</div>
180191
<div class='bb-capture-editor-drag-info'>${loadIcon("rect")}</div>
181192
<div class="bb-capture-toolbar">
193+
<div class="bb-capture-toolbar-item bb-capture-item-rec bb-capture-toolbar-item-tool drag-handle-item" data-type="drag">
194+
${loadIcon("drag")}
195+
</div>
182196
${this.type === "capture"
183197
? `<div class="bb-capture-toolbar-item bb-capture-item-rec bb-capture-toolbar-item-recording" data-type="recording">
184198
${loadIcon("recorderon")}
@@ -397,6 +411,67 @@ export default class GleapMarkerManager {
397411

398412
setupToolbar() {
399413
const self = this;
414+
const toolbar = document.querySelector(".bb-capture-toolbar");
415+
let isDragging = false;
416+
let currentX;
417+
let currentY;
418+
let initialX;
419+
let initialY;
420+
let xOffset = 0;
421+
let yOffset = 0;
422+
423+
const getTransformValues = () => {
424+
const transform = window.getComputedStyle(toolbar).transform;
425+
if (transform === 'none') return { x: 0, y: 0 };
426+
const matrix = new DOMMatrix(transform);
427+
return { x: matrix.m41, y: matrix.m42 };
428+
};
429+
430+
this.dragStart = (e) => {
431+
const { x, y } = getTransformValues();
432+
xOffset = x;
433+
yOffset = y;
434+
435+
if (e.type === "mousedown") {
436+
initialX = e.clientX - xOffset;
437+
initialY = e.clientY - yOffset;
438+
} else {
439+
initialX = e.touches[0].clientX - xOffset;
440+
initialY = e.touches[0].clientY - yOffset;
441+
}
442+
isDragging = true;
443+
};
444+
445+
this.dragEnd = () => {
446+
isDragging = false;
447+
};
448+
449+
this.drag = (e) => {
450+
if (isDragging) {
451+
e.preventDefault();
452+
if (e.type === "mousemove") {
453+
currentX = e.clientX - initialX;
454+
currentY = e.clientY - initialY;
455+
} else {
456+
currentX = e.touches[0].clientX - initialX;
457+
currentY = e.touches[0].clientY - initialY;
458+
}
459+
460+
xOffset = currentX;
461+
yOffset = currentY;
462+
463+
toolbar.style.transform = `translate(${currentX}px, ${currentY}px)`;
464+
}
465+
};
466+
467+
const dragHandle = document.querySelector(".bb-capture-toolbar-item[data-type='drag']");
468+
469+
dragHandle.addEventListener("mousedown", this.dragStart);
470+
dragHandle.addEventListener("touchstart", this.dragStart);
471+
document.addEventListener("mousemove", this.drag);
472+
document.addEventListener("touchmove", this.drag);
473+
document.addEventListener("mouseup", this.dragEnd);
474+
document.addEventListener("touchend", this.dragEnd);
400475

401476
// Hook up dismiss button
402477
const dismissButton = document.querySelector(".bb-capture-dismiss");

src/UI.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,17 @@ export const injectStyledCSS = (
12841284
position: relative;
12851285
margin-right: 5px;
12861286
}
1287+
1288+
.drag-handle-item {
1289+
cursor: grab !important;
1290+
width: 34px;
1291+
min-width: 34px;
1292+
}
1293+
1294+
.drag-handle-item svg {
1295+
width: 18px !important;
1296+
height: 18px !important;
1297+
}
12871298
12881299
.bb-capture-toolbar-item svg {
12891300
width: 23px;
@@ -2305,6 +2316,10 @@ export const loadIcon = function (name, color) {
23052316
</svg>`;
23062317
}
23072318

2319+
if (name === "drag") {
2320+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M64 128a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm0 160a32 32 0 1 0 0-64 32 32 0 1 0 0 64zM96 416a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm96-288a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm32 128a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM192 448a32 32 0 1 0 0-64 32 32 0 1 0 0 64z"/></svg>`;
2321+
}
2322+
23082323
if (name === "unmute") {
23092324
return `<svg id="tooltip-svg-unmute" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path id="tooltip-svg-unmute-path" d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.1 386.2C556.7 352 576 306.3 576 256c0-60.1-27.7-113.8-70.9-149c-10.3-8.4-25.4-6.8-33.8 3.5s-6.8 25.4 3.5 33.8C507.3 170.7 528 210.9 528 256c0 39.1-15.6 74.5-40.9 100.5L449 326.6c19-17.5 31-42.7 31-70.6c0-30.1-13.9-56.9-35.4-74.5c-10.3-8.4-25.4-6.8-33.8 3.5s-6.8 25.4 3.5 33.8C425.1 227.6 432 241 432 256s-6.9 28.4-17.7 37.3c-1.3 1-2.4 2.2-3.4 3.4L352 250.6V64c0-12.6-7.4-24-18.9-29.2s-25-3.1-34.4 5.3L197.8 129.8 38.8 5.1zM352 373.3L82.9 161.3C53.8 167.4 32 193.1 32 224v64c0 35.3 28.7 64 64 64h67.8L298.7 471.9c9.4 8.4 22.9 10.4 34.4 5.3S352 460.6 352 448V373.3z"/></svg>`;
23102325
}

0 commit comments

Comments
 (0)