-
Notifications
You must be signed in to change notification settings - Fork 213
/
example.html
201 lines (181 loc) · 5.88 KB
/
example.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<meta charset="utf8">
<title>Slip.js — sortable and swipeable views</title>
<meta name="viewport" content="width=device-width, user-scalable=no, maximum-scale=1.0">
<style>
/* these are special */
.slip-reordering {
box-shadow: 0 2px 10px rgba(0,0,0,0.45);
}
.slip-swiping-container {
overflow-x: hidden;
}
.slippylist li {
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
cursor: default;
}
/* the rest is junk for the demo page */
.slippylist li.demo-allow-select {
padding: 1em;
line-height: 1.3;
user-select: text;
-moz-user-select: text;
-webkit-user-select: text;
}
.slippylist li.demo-allow-select span {
cursor: text;
}
body {
background: #eee;
font-family: Helvetica, Arial, sans-serif;
max-width: 40em;
margin: 0 auto;
padding: 5px;
}
.slippylist {
clear:left;
margin: 1em;
padding: 0 0 1px;
}
.slippylist li {
display: block;
position: relative;
border: 1px solid black;
background: white;
margin: 0; padding: 0 1em;
border-radius: 3px;
margin-bottom: -1px;
max-width: 100%;
line-height: 3;
vertical-align: middle;
}
.slippylist input {
vertical-align: middle;
}
.slippylist .instant::after {
content: " \2261";
}
.slippylist .instant {
float: right;
}
.skewed {
transform: rotate(2deg) scale(0.99);
-webkit-transform: rotate(2deg) scale(0.99);
}
.demo-no-swipe.demo-no-reorder {
opacity: 0.5;
}
#scroll {
overflow-y: scroll;
max-height: 300px;
}
h1, h2, h3 {
color: #666;
}
h1 {
float:left;
margin-top: 0;
margin-right: 1ex;
}
h3 {
margin-bottom: 0.2em;
margin-top: 2em;
}
h1+p {
overflow:auto;
margin-top: 0.2em;
}
</style>
<body>
<h1>Slip.js</h1>
<p>Swiping and reordering lists of elements on touch screens, no fuss. A tiny library by <a href="//twitter.com/kornelski">Kornel</a>.</p>
<ol id="demo1" class="slippylist">
<li class="demo-no-reorder">Swipe,</li>
<li class="demo-no-swipe">hold & reorder <span class="instant">or instantly</span></li>
<li>or either</li>
<li class="demo-no-swipe demo-no-reorder">or none of them.</li>
<li>Can play nicely with:</li>
<li>interaction <input type="range"></li>
<li style="transform: scaleX(0.97) skewX(-10deg); -webkit-transform: scaleX(0.97) skewX(-10deg)">inline CSS transforms</li>
<li class="skewed">stylesheet transforms</li>
<li class="demo-allow-select"><span class="demo-no-reorder">and selectable text, even though animating elements with selected text is a bit weird.</span></li>
<li>iOS Safari</li>
<li>Mobile Chrome</li>
<li>Android Firefox</li>
<li>Opera Presto and Blink</li>
<li>No dependencies</li>
</ol>
<h3>Demo inside of a scroll container</h3>
<div id="scroll">
<ol id="demo2" class="slippylist">
<li class="demo-no-reorder">Swipe,</li>
<li class="demo-no-swipe">hold & reorder <span class="instant">or instantly</span></li>
<li>or either</li>
<li class="demo-no-swipe demo-no-reorder">or none of them.</li>
<li>Can play nicely with:</li>
<li>interaction <input type="range"></li>
<li style="transform: scaleX(0.97) skewX(-10deg); -webkit-transform: scaleX(0.97) skewX(-10deg)">inline CSS transforms</li>
<li class="skewed">stylesheet transforms</li>
<li class="demo-allow-select"><span class="demo-no-reorder">and selectable text, even though animating elements with selected text is a bit weird.</span></li>
<li>iOS Safari</li>
<li>Mobile Chrome</li>
<li>Android Firefox</li>
<li>Opera Presto and Blink</li>
<li>No dependencies</li>
</ol>
</div>
<h3>Demo of nested list</h3>
<ol id="demo3" class="slippylist">
<li class="demo-no-reorder">Swipe,</li>
<li class="demo-no-swipe">hold & reorder <span class="instant">or instantly</span></li>
<li class="demo-no-swipe demo-no-reorder">or none of them.</li>
<li style="transform: scaleX(0.97) skewX(-10deg); -webkit-transform: scaleX(0.97) skewX(-10deg)">inline CSS transforms</li>
<li class="skewed">stylesheet transforms</li>
<li>
<ol id="demo-nested" class="slippylist">
<li>We are</li>
<li>a nested list</li>
<li>with ordering and swipe support</li>
</ol>
</li>
<li>Mobile Chrome</li>
</ol>
<h2>Known limitations</h2>
<ul>
<li>Tap & hold is too sensitive in Firefox (W3C TouchEvents specification is ambiguous about sensitivity of touch movements, so strictly speaking that's a spec bug, not a browser bug.)</li>
<li>There are few bits in animations that could be smoother or more efficient.</li>
</ul>
<p><a href="https://github.com/kornelski/slip">Bug/fork/star on GitHub</a>.</p>
<script src="slip.js"></script>
<script>
function setupSlip(list) {
list.addEventListener('slip:beforereorder', function(e){
if (e.target.classList.contains('demo-no-reorder')) {
e.preventDefault();
}
}, false);
list.addEventListener('slip:beforeswipe', function(e){
if (e.target.nodeName == 'INPUT' || e.target.classList.contains('demo-no-swipe')) {
e.preventDefault();
}
}, false);
list.addEventListener('slip:beforewait', function(e){
if (e.target.classList.contains('instant')) e.preventDefault();
}, false);
list.addEventListener('slip:afterswipe', function(e){
e.target.parentNode.appendChild(e.target);
}, false);
list.addEventListener('slip:reorder', function(e){
e.target.parentNode.insertBefore(e.target, e.detail.insertBefore);
return false;
}, false);
return new Slip(list);
}
setupSlip(document.getElementById('demo1'));
setupSlip(document.getElementById('demo2'));
setupSlip(document.getElementById('demo3'));
setupSlip(document.getElementById('demo-nested'));
</script>