forked from godswearhats/jquery-ui-rotatable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
80 lines (74 loc) · 2.92 KB
/
demo.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
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.11.3.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="jquery.ui.rotatable.js"></script>
<link rel="stylesheet" href="jquery.ui.rotatable.css">
<script type="text/javascript">
$(document).ready(function() {
var params = {
start: function(event, ui) {
console.log("Rotating started");
},
rotate: function(event, ui) {
console.log("Rotating");
},
stop: function(event, ui) {
console.log("Rotating stopped");
},
};
$('#target').rotatable(params);
$('#target2').rotatable(); $('#draggable2').draggable();
$('#target3').resizable().rotatable(); $('#draggable3').draggable();
$('#target4').rotatable( {angle: 0.1} );
$('#target5').rotatable( {handle: $(document.createElement('img')).attr('src', 'alternate_rotate.png')} );
$('#target6').rotatable( {snap: true} );
$('#target7').rotatable( {wheelRotate: false} );
$('#target8').rotatable({
rotate: function(e, ui){
var degrees = ui.angle.current * 180/Math.PI;
if ( degrees < 0 ) degrees += 360;
// contain angle between 0 and 180 degrees
if ( degrees > 270 ) {
ui.angle.current = 0;
} else if ( degrees > 180 ) {
ui.angle.current = Math.PI;
}
}
});
});
</script>
</head>
<body>
<div id="target" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px">
Rotate me! (I have callbacks logging to the console)
</div>
<div id="draggable2">
<div id="target2" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px">
Drag me and rotate me!
</div>
</div>
<div id="draggable3">
<div id="target3" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px;">
Drag me, resize me and rotate me!
</div>
</div>
<div id="target4" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
I start rotated.
</div>
<div id="target5" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
I've got a custom handle.
</div>
<div id="target6" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
I snap every 22.5°.
</div>
<div id="target7" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
I don't rotate on wheel.
</div>
<div id="target8" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px">
I only rotate between 0 and 180 degrees.
</div>
</div>
</body>
</html>