forked from kornelski/slip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testDetach.html
162 lines (140 loc) · 3.92 KB
/
testDetach.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
<!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>
<button id="attach" type="button">Attach</button><button id="detach" type="button">Detach</button>
<script src="slip.js"></script>
<script>
function beforereorder(e) {
if (e.target.classList.indexOf('demo-no-reorder') >= 0) {
e.preventDefault();
}
}
function reorder(e){
e.target.parentNode.insertBefore(e.target, e.detail.insertBefore);
return false;
}
function setupSlip(list) {
list.addEventListener('slip:beforereorder', beforereorder, false);
list.addEventListener('slip:reorder', reorder, false);
return new Slip(list);
}
function Attach(e) {
e.target.removeEventListener('click', Attach, false);
document.demo1SlipObj = setupSlip(document.getElementById('demo1'));
document.getElementById("detach").addEventListener('click', Detach, false);
}
function Detach(e) {
e.target.removeEventListener('click', Detach, false);
document.demo1SlipObj.detach();
delete document.demo1SlipObj;
document.getElementById("attach").addEventListener('click', Attach, false);
}
document.getElementById("attach").addEventListener('click', Attach, false);
</script>