-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (30 loc) · 969 Bytes
/
Copy pathscript.js
File metadata and controls
35 lines (30 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const lists = document.querySelectorAll('.board .list');
const cards = document.querySelectorAll('.board .list .card');
// Make cards draggable
cards.forEach(card => {
card.addEventListener('dragstart', (e) => {
card.classList.add('active');
});
card.addEventListener('dragend', (e) => {
card.classList.remove('active');
lists.forEach(list => list.classList.remove('over'));
});
});
// Handle drag over lists
lists.forEach(list => {
list.addEventListener('dragover', (e) => {
e.preventDefault();
list.classList.add('over');
});
list.addEventListener('dragleave', () => {
list.classList.remove('over');
});
list.addEventListener('drop', (e) => {
e.preventDefault();
const activeCard = document.querySelector('.card.active');
if (activeCard) {
list.appendChild(activeCard);
}
list.classList.remove('over');
});
});