DmitrMakeev commited on
Commit
e411f8a
·
verified ·
1 Parent(s): ddeb307

Update builder.html

Browse files
Files changed (1) hide show
  1. builder.html +26 -18
builder.html CHANGED
@@ -8,19 +8,26 @@
8
  <link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
9
 
10
  <!-- Your Custom CSS -->
11
- <style>
12
  .gjs-row {
13
  display: flex;
14
  justify-content: space-between;
15
  width: 100%;
16
  height: 100px;
17
  border: 1px dashed #ccc; /* Добавляем контур для строк */
 
18
  }
19
  .gjs-cell {
20
  flex: 1;
21
  border: 1px solid #ccc; /* Добавляем контур для ячеек */
22
  padding: 10px;
23
  text-align: center;
 
 
 
 
 
 
24
  }
25
  </style>
26
  </head>
@@ -61,27 +68,28 @@
61
  attributes: { class: 'gjs-block-section' }
62
  });
63
 
 
64
  document.addEventListener('DOMContentLoaded', function() {
65
- var buttons = document.querySelectorAll('.draggable');
66
- var offsetX = 0, offsetY = 0, isDragging = false;
67
 
68
- buttons.forEach(button => {
69
- button.addEventListener('mousedown', function(e) {
70
- isDragging = true;
71
- offsetX = e.clientX - button.offsetLeft;
72
- offsetY = e.clientY - button.offsetTop;
73
- });
 
74
 
75
- document.addEventListener('mousemove', function(e) {
76
- if (isDragging) {
77
- button.style.left = (e.clientX - offsetX) + 'px';
78
- button.style.top = (e.clientY - offsetY) + 'px';
79
- }
80
- });
81
 
82
- document.addEventListener('mouseup', function(e) {
83
- isDragging = false;
84
- });
85
  });
86
  });
87
  </script>
 
8
  <link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
9
 
10
  <!-- Your Custom CSS -->
11
+ <style>
12
  .gjs-row {
13
  display: flex;
14
  justify-content: space-between;
15
  width: 100%;
16
  height: 100px;
17
  border: 1px dashed #ccc; /* Добавляем контур для строк */
18
+ margin-bottom: 10px;
19
  }
20
  .gjs-cell {
21
  flex: 1;
22
  border: 1px solid #ccc; /* Добавляем контур для ячеек */
23
  padding: 10px;
24
  text-align: center;
25
+ margin: 0 5px; /* Добавляем отступы между ячейками */
26
+ position: relative; /* Для корректного перемещения кнопок */
27
+ }
28
+ .draggable {
29
+ position: absolute;
30
+ cursor: move;
31
  }
32
  </style>
33
  </head>
 
68
  attributes: { class: 'gjs-block-section' }
69
  });
70
 
71
+ // Simplified drag and drop functionality for buttons
72
  document.addEventListener('DOMContentLoaded', function() {
73
+ let currentButton = null;
74
+ let offsetX = 0, offsetY = 0;
75
 
76
+ document.addEventListener('mousedown', function(e) {
77
+ if (e.target.classList.contains('draggable')) {
78
+ currentButton = e.target;
79
+ offsetX = e.clientX - currentButton.offsetLeft;
80
+ offsetY = e.clientY - currentButton.offsetTop;
81
+ }
82
+ });
83
 
84
+ document.addEventListener('mousemove', function(e) {
85
+ if (currentButton) {
86
+ currentButton.style.left = (e.clientX - offsetX) + 'px';
87
+ currentButton.style.top = (e.clientY - offsetY) + 'px';
88
+ }
89
+ });
90
 
91
+ document.addEventListener('mouseup', function() {
92
+ currentButton = null;
 
93
  });
94
  });
95
  </script>