-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
133 lines (115 loc) · 3.74 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DragScroll.js</title>
</head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css" />
<style>
body {
background-color: #f1f1f1;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
line-height: 1.6;
font-size: 16px;
}
html, body, .container, .drag-section {
height: 100%;
}
h1 {
margin-top: 0;
margin-bottom: 15px;
}
p {
margin-top: 0;
margin-bottom: 20px;
}
.container {
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
position: relative;
}
* {
box-sizing: border-box;
}
.drag-section {
height: 500px;
padding: 1rem;
background-color: #fff;
border-radius: 4px;
border: 1px solid #eaeaea;
overflow: auto;
cursor: grab;
}
.drag-section:active {
cursor: grabbing;
}
.articles {
width: 200%;
height: 200%;
flex-wrap: wrap;
display: flex;
overflow: hidden;
}
article {
flex: 0 0 50%;
min-width: 50%;
max-width: 50%;
}
article[nodrag] {
cursor: default;
}
</style>
<body>
<div class="container">
<h1>DragScroll.js</h1>
<p>Try dragging inside the box.</p>
<div class="drag-section drag-scroll">
<div class="articles">
<article>
<h2>Lorem ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
<article>
<h2>Lorem ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
<article>
<h2>Lorem ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
<article>
<h2>Lorem ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
<article style="color: red" nodrag>
<h2>You can select text here</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
<article>
<h2>Lorem ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
<article>
<h2>Lorem ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla feugiat sem quis quam aliquam fringilla a vitae ipsum. Curabitur sagittis fermentum malesuada. Phasellus ultrices urna diam, sit amet convallis metus mollis placerat.</p>
</article>
</div>
</div>
</div>
<script src="dist/drag-scroll.js"></script>
<script>
const el = document.querySelector('.drag-scroll');
let ds = new DragScroll({
el: el
});
setTimeout(() => {
ds.destroy();
}, 2000);
setTimeout(() => {
ds.init();
}, 3000);
</script>
</body>
</html>