forked from godswearhats/jquery-ui-rotatable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
93 lines (88 loc) · 3.65 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
81
82
83
84
85
86
87
88
89
90
91
92
93
<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) {
if (Math.abs(ui.angle.current > 6)) {
console.log("Rotating " + ui.angle.current)
}
},
stop: function(event, ui) {
console.log("Rotating stopped")
},
};
$('#target').rotatable(params)
$('#target2').rotatable(); $('#draggable2').draggable()
$('#target3').resizable().rotatable(); $('#draggable3').draggable()
$('#target4').rotatable( {degrees: 20} )
$('#target5').rotatable( {handle: $(document.createElement('img')).attr('src', 'alternate_rotate.png')} )
$('#target5-1').rotatable( {handleOffset: {left: 200}} )
$('#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
}
}
});
$('#target9').rotatable( {transforms: {scaleY: 2}} )
$('#target10').rotatable( {rotationCenterOffset: {left: 250}})
});
</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="target5-1" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
My handle has been offset
</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; margin-bottom: 40px">
I only rotate between 0 and 180 degrees.
</div>
<div id="target9" style="width: 250px; border: 1px solid #862dde; padding: 0px; padding-right: 40px">
I have a scaleY(2) transform applied to me
</div>
<div id="target10" style="width: 250px; border: 1px solid #862dde; padding: 20px; margin-top: 40px">
My rotation center has been offset to on my far right!
</div>
</div>
</body>
</html>