-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
104 lines (83 loc) · 1.55 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
<!DOCTYPE html>
<html>
<head>
<title>ViinyDragger</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="src/index.js"></script>
<style type="text/css">
#draggable_obj {
left: 0;
top: 0;
}
#draggable_obj_2 {
left: 100px;
top: 0;
}
#draggable_obj_3 {
left: 0;
top: 0;
}
.draggable {
position: absolute;
left: 0;
top: 0;
}
.blue {
background: blue;
color: white;
}
.red {
background: red;
color: white;
}
.orange {
background: orange;
color: white;
}
.box {
width: 50px;
height: 50px;
padding: 10px;
text-align: center;
}
.active-box {
opacity: 0.5;
border: 1px solid #333333;
}
#restrict_obj {
width: 300px;
height: 200px;
left: 300px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div id="draggable_obj" class="draggable box blue">
Drag Me
</div>
<div id="draggable_obj_2" class="draggable box red">
Drag Me
</div>
<div id="restrict_obj">
<div id="draggable_obj_3" class="draggable box orange">
Drag Me
</div>
</div>
<script type="text/javascript">
var obj = document.getElementById('draggable_obj_2'),
obj2 = document.getElementById('draggable_obj_3');
viiny.dragger(obj, {
activeClass: 'active-box',
snapX: 50,
onStop: function (e, obj) {
console.log(e.distanceY);
}
});
viiny.dragger(obj2, {
activeClass: 'active-box',
restrict: document.getElementById('restrict_obj')
});
</script>
</body>
</html>