Skip to content

Commit 2cb6d50

Browse files
committed
Minor bug fixes
I missed a few bugs in my haste to make a release. Went through and fixed those, and also changed the `steps` option to `step` as that seemed to make more semantic sense.
1 parent 988d34e commit 2cb6d50

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
jquery-ui-rotatable is a plugin for jQuery UI that works in a similar way to Draggable and Resizable, without being as full-featured (please fork and send me pull requests!). By default, it puts a small rotation icon in the bottom left of whatever element you want to make rotatable. I chose that area because it was originally being used in [Herald](https://github.com/godswearhats/herald) and the elements in that project were also resizable and I didn't want to interfere with the bottom/right controls for that.
1+
jquery-ui-rotatable is a plugin for jQuery UI that works in a similar way to Draggable and Resizable, without being as full-featured (please fork and send me pull requests!). By default, it puts a small rotation icon in the bottom left of whatever element you want to make rotatable.
22

33
### Usage
44

55
Somewhere in your HTML ...
66

77
<!-- prerequisites -->
88
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
9-
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
10-
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
9+
<script src="http://code.jquery.com/jquery-1.11.3.js"></script>
10+
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
1111

1212
<script src="jquery.ui.rotatable.js"></script>
1313
<!-- this is small and will allow you to override look/feel of handle -->
@@ -42,8 +42,8 @@ Options that can be set when you call `.rotatable()` are:
4242
* handle: url to a custom image for the handle
4343
* angle: the starting rotation for the element (default 0 degrees)
4444
* rotationCenterX, rotationCenterY: position about which the element will be rotated
45-
* steps: an angle in degrees that the rotation will snap to if the shift key is held (default 22.5)
46-
* snap: snaps to step in degrees, even if shift key is not held (default: false)
45+
* step: an angle in degrees that the rotation will snap to if the shift key is held (default 22.5)
46+
* snap: snaps to `step` in degrees (default: false)
4747
* start, stop, rotate: callbacks when those events occur
4848

4949
The start, rotate and stop callbacks provide the following in the ui argument of the callback:
@@ -68,7 +68,7 @@ A simple demo is in the source code, but can be visited [here](http://godswearha
6868

6969
### Thanks
7070

71-
Many thanks to those of you who have reported issues and helped me diagnose and fix them! Specifically, @thehunmonkgroup, @ssimono, @theodorton, @rouxguigui and @tremez
71+
Many thanks to those of you who have reported issues and helped me diagnose and fix them! Also, thank you to all the contributors who have sent pull requests and put up with my laziness :-)
7272

7373
### License
7474

demo.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<html>
22
<head>
33
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
4-
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
5-
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
4+
<script src="http://code.jquery.com/jquery-1.11.3.js"></script>
5+
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
66

77
<script src="jquery.ui.rotatable.min.js"></script>
88
<link rel="stylesheet" href="jquery.ui.rotatable.css">
@@ -21,16 +21,18 @@
2121
},
2222
};
2323
$('#target').rotatable(params);
24-
$('#target2').rotatable(params); $('#draggable2').draggable();
25-
$('#target3').resizable().rotatable(params); $('#draggable3').draggable();
24+
$('#target2').rotatable(); $('#draggable2').draggable();
25+
$('#target3').resizable().rotatable(); $('#draggable3').draggable();
2626
$('#target4').rotatable( {angle: 0.1} );
2727
$('#target5').rotatable( {handle: $(document.createElement('img')).attr('src', 'alternate_rotate.png')} );
28+
$('#target6').rotatable( {snap: true} );
29+
2830
});
2931
</script>
3032
</head>
3133
<body>
3234
<div id="target" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px">
33-
Rotate me!
35+
Rotate me! (I have callbacks logging to the console)
3436
</div>
3537
<div id="draggable2">
3638
<div id="target2" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px">
@@ -48,5 +50,8 @@
4850
<div id="target5" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
4951
I've got a custom handle.
5052
</div>
53+
<div id="target6" style="width: 250px; border: 1px solid #862dde; padding: 20px; padding-right: 40px; margin-top: 20px">
54+
I snap every 22.5&deg;.
55+
</div>
5156
</body>
5257
</html>

jquery.ui.rotatable.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $.widget("ui.rotatable", $.ui.mouse, {
66
handle: false,
77
angle: false,
88
snap: false,
9-
steps: 22.5,
9+
step: 22.5,
1010

1111

1212
rotationCenterX: false,
@@ -150,7 +150,7 @@ $.widget("ui.rotatable", $.ui.mouse, {
150150
return false;
151151
}
152152

153-
var rotateAngle = this.getRotateAngle();
153+
var rotateAngle = this.getRotateAngle(event);
154154

155155
this.performRotation(rotateAngle);
156156
var previousRotateAngle = this.elementCurrentAngle;
@@ -184,7 +184,7 @@ $.widget("ui.rotatable", $.ui.mouse, {
184184
return false;
185185
},
186186

187-
getRotateAngle: function(){
187+
getRotateAngle: function(event){
188188

189189
var center = this.getElementCenter();
190190

@@ -199,7 +199,7 @@ $.widget("ui.rotatable", $.ui.mouse, {
199199
var rotateDegrees = ( ( rotateAngle / Math.PI ) * 180 );
200200

201201
//round to nearest step
202-
rotateDegrees = Math.round( rotateDegrees / this.options.steps ) * this.options.steps;
202+
rotateDegrees = Math.round( rotateDegrees / this.options.step ) * this.options.step;
203203

204204
//convert it back to radians
205205
rotateAngle = ( rotateDegrees * Math.PI ) / 180;

jquery.ui.min.js renamed to jquery.ui.rotatable.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)