-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
164 lines (149 loc) · 4.66 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Drag Select</title>
<meta name="description" content="Small and functional JavaScript drag-select demonstration">
<style>
html, body {
width: 100%;
height: 150%;
margin: 0;
}
.main {
height: 444px;
width: 444px;
overflow: auto;
gap: 8px;
justify-content: center;
margin: 4px;
border: 8px dashed black;
padding: 8px;
}
.main-wrapper {
border: 2px solid gray;
}
.main-1 {
display: flex;
flex-wrap: wrap;
}
.main-1 .drag-selectable-wrap {
width: 100%;
margin: 0;
}
.main-1 .drag-selectable {
width: 50px;
height: 50px;
}
.main-4 .drag-selectable-wrap {
margin: 0;
flex-wrap: nowrap;
justify-content: start;
height: 100%;
}
.main-4 .drag-selectable {
flex-shrink: 0;
flex-grow: 0;
width: 50px;
height: 150px;
}
.debug-wrapper {
margin: 20px 10px;
overflow: auto;
white-space: nowrap;
}
.debug-2 {top: 25px;}
.debug-3 {top: 45px;}
.debug-4 {top: 65px;}
.drag-selectable-wrap {
margin: 15px 150px;
width: 535px;
display: flex;
flex-wrap: wrap;
gap: 15px;
justify-content: center;
align-items: center;
}
.drag-selectable {
width: 150px;
height: 50px;
border: 5px solid transparent;
display: flex;
justify-content: center;
align-items: center;
color: white;
text-shadow: 0 0 8px black;
}
.drag-select-area {
background-color: hsl(210deg 80% 50% / 50%);
border: 1px solid hsl(210deg 80% 50% / 75%);
box-sizing: border-box;
}
.drag-selected {
border: 5px solid black;
}
.readme {
position: fixed;
bottom: 0;
right: 0;
padding: 2px 8px;
margin: 1px;
color: #a9a9a9;
text-decoration: none;
}
</style>
</head>
<body>
<a class="readme" title="Open Readme" href="https://github.com/AlttiRi/drag-select-demo#drag-select-demo" target="_blank" rel="noopener"><i>i</i></a>
<div class="debug-wrapper">
<div class="debug debug-1"> </div>
<div class="debug debug-2"> </div>
<div class="debug debug-3"> </div>
<div class="debug debug-4"> </div>
</div>
<div class="examples" style="
gap: 55px;
justify-content: center;
display: flex;
flex-wrap: wrap;">
<div class="main main-1" title="No scrolls"></div>
<div class="main main-2" title="With scrolls"></div>
<div class="main main-3" title="With scrolls and RTL" style="direction: rtl;"></div>
<div class="main main-4" title="With h-scroll and RTL" style="direction: rtl;"></div>
<div class="main-wrapper" title="With scrolls, outer v-scroll" style="height: 400px; overflow-y: scroll;">
<div class="main main-5"></div>
</div>
<div class="main-wrapper" title="With scrolls, outer v-scroll and RTL" style="height: 400px; overflow-y: scroll; direction: rtl;">
<div class="main main-6"></div>
</div>
</div>
<script type="module">
import {dragSelect} from "./index.js";
import {debugInfo} from "./debug.js";
globalThis.debugInfo = debugInfo;
const contElem1 = document.querySelector(".main-1");
initHtml(contElem1, 20);
dragSelect(contElem1);
for (let i = 2; i <= 6; i++) {
const contElem = document.querySelector(`.main-${i}`);
initHtml(contElem);
dragSelect(contElem);
}
function initHtml(insertPlace, count = 80) {
const divWrap = document.createElement("div");
divWrap.classList.add("drag-selectable-wrap");
for (let i = 0; i < count; i++) {
const div = document.createElement("div");
const text = document.createElement("div");
text.textContent = String(i);
div.style.backgroundColor = `hsl(${Math.random() * 360}, 100%, 45%)`;
div.classList.add("drag-selectable");
div.append(text);
divWrap.append(div);
}
insertPlace.append(divWrap);
}
</script>
</body>
</html>