Skip to content

Commit dfd6f72

Browse files
trash bin
1 parent 8d43e87 commit dfd6f72

File tree

1 file changed

+83
-3
lines changed

1 file changed

+83
-3
lines changed

index.html

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@
525525
margin-top: -30vh; /* Adjusted for landscape mode */
526526
height: 50vh;
527527
}
528-
// ...rest of media query...
529528
}
530529

531530
.pagination-controls {
@@ -628,6 +627,33 @@
628627
.scene-name {
629628
flex-grow: 1;
630629
}
630+
631+
.trash-bin {
632+
position: fixed;
633+
bottom: 73%; /* Changed from bottom: 20px */
634+
left: 50px;
635+
width: 50px;
636+
height: 50px;
637+
background: rgba(255, 0, 0, 0.2);
638+
border: 2px dashed #ff0000;
639+
border-radius: 8px;
640+
display: flex;
641+
justify-content: center;
642+
align-items: center;
643+
font-size: 24px;
644+
z-index: 1000;
645+
transition: all 0.3s ease;
646+
transform: translateY(50%); /* Added to center vertically */
647+
}
648+
649+
.trash-bin.drag-over {
650+
background: rgba(255, 0, 0, 0.4);
651+
transform: scale(1.1);
652+
}
653+
654+
.trash-bin.hidden {
655+
display: none;
656+
}
631657
</style>
632658

633659
<!-- Add these scripts in the head section -->
@@ -764,6 +790,8 @@
764790
</div>
765791
</div>
766792

793+
<div class="trash-bin hidden" id="trashBin">🗑️</div>
794+
767795
<script src="dragndrop.js"></script>
768796
<script>
769797
// Add loading screen handler at the start of your scripts
@@ -1168,6 +1196,7 @@
11681196
initialX = touch.clientX - element.offsetLeft;
11691197
initialY = touch.clientY - element.offsetTop;
11701198
isDragging = true;
1199+
handleDragStart();
11711200
}
11721201

11731202
function handleTouchMove(e) {
@@ -1178,17 +1207,23 @@
11781207
currentY = touch.clientY - initialY;
11791208
element.style.left = `${currentX}px`;
11801209
element.style.top = `${currentY}px`;
1210+
handleDrag(touch.clientX, touch.clientY);
11811211
}
11821212
}
11831213

1184-
function handleTouchEnd() {
1214+
function handleTouchEnd(e) {
1215+
if (isDragging) {
1216+
const touch = e.changedTouches[0];
1217+
handleDragEnd(touch.clientX, touch.clientY);
1218+
}
11851219
isDragging = false;
11861220
}
11871221

11881222
function startDragging(e) {
11891223
initialX = e.clientX - element.offsetLeft;
11901224
initialY = e.clientY - element.offsetTop;
11911225
isDragging = true;
1226+
handleDragStart();
11921227
}
11931228

11941229
function drag(e) {
@@ -1198,12 +1233,57 @@
11981233
currentY = e.clientY - initialY;
11991234
element.style.left = `${currentX}px`;
12001235
element.style.top = `${currentY}px`;
1236+
handleDrag(e.clientX, e.clientY);
12011237
}
12021238
}
12031239

1204-
function stopDragging() {
1240+
function stopDragging(e) {
1241+
if (isDragging) {
1242+
handleDragEnd(e.clientX, e.clientY);
1243+
}
12051244
isDragging = false;
12061245
}
1246+
1247+
const trashBin = document.getElementById('trashBin');
1248+
1249+
function showTrashBin() {
1250+
trashBin.classList.remove('hidden');
1251+
}
1252+
1253+
function hideTrashBin() {
1254+
trashBin.classList.remove('drag-over');
1255+
trashBin.classList.add('hidden');
1256+
}
1257+
1258+
function handleDragStart() {
1259+
showTrashBin();
1260+
}
1261+
1262+
function handleDrag(x, y) {
1263+
const trashRect = trashBin.getBoundingClientRect();
1264+
const isOverTrash = x >= trashRect.left && x <= trashRect.right &&
1265+
y >= trashRect.top && y <= trashRect.bottom;
1266+
1267+
if (isOverTrash) {
1268+
trashBin.classList.add('drag-over');
1269+
} else {
1270+
trashBin.classList.remove('drag-over');
1271+
}
1272+
}
1273+
1274+
function handleDragEnd(x, y) {
1275+
const trashRect = trashBin.getBoundingClientRect();
1276+
const isOverTrash = x >= trashRect.left && x <= trashRect.right &&
1277+
y >= trashRect.top && y <= trashRect.bottom;
1278+
1279+
if (isOverTrash) {
1280+
element.remove();
1281+
if (currentScene) {
1282+
saveSceneBtn.disabled = false;
1283+
}
1284+
}
1285+
hideTrashBin();
1286+
}
12071287
}
12081288

12091289
function exportScenes() {

0 commit comments

Comments
 (0)