-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.html
113 lines (99 loc) · 2.99 KB
/
index.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Balloons</title>
<style>
body {
box-sizing: border-box;
margin: 0;
padding: 0;
}
#app-container {
width: 80%;
min-height: calc(100vh - 2px);
padding: 1px;
margin: 0 auto;
background-color: lightblue;
}
.item {
display: inline-block;
padding: 20px;
border: 1px solid black;
background-color: orange;
}
#board {
margin: 20px;
display: flex;
justify-content: center;
height: 250px;
}
#board .column {
width: 15vw;
border: 1px solid black;
border-right: 0;
padding: 5px;
}
#board .column:last-of-type {
border-right: 1px solid black;
}
#board .column .content {
display: flex;
padding: 5px;
flex-direction: column;
height: 100%;
}
</style>
</head>
<body>
<div id="app-container">
<div id="walkme-controls">
<button onclick="walkme.play()">Help</button>
</div>
<div id="board">
<div class="column">
<header>Column 1</header>
<div class="content drop-zone">
<span id="item1" class="item" draggable="true"><b>I'm the target</b></span>
</div>
</div>
<div class="column">
<header>Column 2</header>
<div class="content drop-zone">
<span id="item2" class="item" draggable="true">I'm not the target</span>
</div>
</div>
<div class="column">
<header>Column 3</header>
<div class="content drop-zone"></div>
</div>
</div>
</div>
<script src="./walkme.js"></script>
<script>
const dropZones = document.querySelectorAll('.drop-zone');
const draggables = document.querySelectorAll('.item');
dropZones.forEach(function (el) {
el.addEventListener('dragover', onDragOver);
el.addEventListener('drop', onDrop);
});
draggables.forEach(function (el) {
el.addEventListener('dragstart', onDragStart);
});
function onDragStart(e) {
e.dataTransfer.setData('text/plain', e.target.id);
}
function onDragOver(e) {
e.preventDefault();
}
function onDrop(e) {
if (!e.target.classList.contains('drop-zone')) return;
const id = e.dataTransfer.getData('text');
const el = document.getElementById(id);
e.target.appendChild(el);
e.dataTransfer.clearData();
}
</script>
</body>
</html>