forked from heyman/jquery-draggable-touch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
51 lines (46 loc) · 2.07 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
<!DOCTYPE html>
<html>
<head>
<title>jQuery Draggable Touch Example</title>
</head>
<body>
<div class="draggable" style="position:absolute; top:50px; left:20; width:200px; height:200px; background:#f00;"></div>
<div class="draggable" style="position:absolute; top:50px; left:20; width:50px; height:50px; background:#f00;"></div>
<div>
<button id="enable">Enable</button>
<button id="disable">Disable</button>
</div>
<div id="console"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="jquery.draggableTouch.js"></script>
<script>
$(document).ready(function() {
$("#enable").click(function() {
$(".draggable").draggableTouch();
});
$("#disable").click(function() {
$(".draggable").draggableTouch("disable");
});
$(".draggable").bind("dragstart", function(e, pos) {
console.log("dragstart:", this, pos.left + "," + pos.top);
}).bind("dragend", function(e, pos) {
console.log("dragend:", this, pos.left + "," + pos.top);
});
});
// if this is a touch device, we assume we don't have a visible console and use
// a crappy homemade one :)
if ("ontouchstart" in document.documentElement) {
window.console = {
log: function(a, b, c) {
if (a && b && c)
$("<div>" + a + " " + b + " " + c + "</div>").appendTo($("#console"));
else if (a && b)
$("<div>" + a + " " + b + "</div>").appendTo($("#console"));
else if (a)
$("<div>" + a + "</div>").appendTo($("#console"));
}
};
}
</script>
</body>
</html>