Update builder.html
Browse files- builder.html +20 -24
builder.html
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
|
10 |
<!-- Your Custom CSS -->
|
11 |
<!-- Your Custom CSS -->
|
|
|
12 |
<style>
|
13 |
.container {
|
14 |
display: flex;
|
@@ -46,40 +47,35 @@
|
|
46 |
label: 'Horizontal Block',
|
47 |
content: `
|
48 |
<div class="container">
|
49 |
-
<div class="item"
|
50 |
-
<div class="item"
|
51 |
-
<div class="item"
|
52 |
</div>
|
53 |
`,
|
54 |
attributes: { class: 'gjs-block-section' }
|
55 |
});
|
56 |
|
57 |
-
// Example of adding a draggable button
|
58 |
-
blockManager.add('draggable-button', {
|
59 |
-
label: 'Draggable Button',
|
60 |
-
content: `<button class="draggable" draggable="true">Давай</button>`,
|
61 |
-
attributes: { class: 'gjs-block-section' }
|
62 |
-
});
|
63 |
-
|
64 |
document.addEventListener('DOMContentLoaded', function() {
|
65 |
-
var
|
66 |
var offsetX = 0, offsetY = 0, isDragging = false;
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
|
|
83 |
});
|
84 |
});
|
85 |
</script>
|
|
|
9 |
|
10 |
<!-- Your Custom CSS -->
|
11 |
<!-- Your Custom CSS -->
|
12 |
+
<!-- Your Custom CSS -->
|
13 |
<style>
|
14 |
.container {
|
15 |
display: flex;
|
|
|
47 |
label: 'Horizontal Block',
|
48 |
content: `
|
49 |
<div class="container">
|
50 |
+
<div class="item"><button class="draggable" draggable="true">Давай</button></div>
|
51 |
+
<div class="item"><button class="draggable" draggable="true">Давай</button></div>
|
52 |
+
<div class="item"><button class="draggable" draggable="true">Давай</button></div>
|
53 |
</div>
|
54 |
`,
|
55 |
attributes: { class: 'gjs-block-section' }
|
56 |
});
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
document.addEventListener('DOMContentLoaded', function() {
|
59 |
+
var buttons = document.querySelectorAll('.draggable');
|
60 |
var offsetX = 0, offsetY = 0, isDragging = false;
|
61 |
|
62 |
+
buttons.forEach(button => {
|
63 |
+
button.addEventListener('mousedown', function(e) {
|
64 |
+
isDragging = true;
|
65 |
+
offsetX = e.clientX - button.offsetLeft;
|
66 |
+
offsetY = e.clientY - button.offsetTop;
|
67 |
+
});
|
68 |
|
69 |
+
document.addEventListener('mousemove', function(e) {
|
70 |
+
if (isDragging) {
|
71 |
+
button.style.left = (e.clientX - offsetX) + 'px';
|
72 |
+
button.style.top = (e.clientY - offsetY) + 'px';
|
73 |
+
}
|
74 |
+
});
|
75 |
|
76 |
+
document.addEventListener('mouseup', function(e) {
|
77 |
+
isDragging = false;
|
78 |
+
});
|
79 |
});
|
80 |
});
|
81 |
</script>
|