jquery-ui-rotatable is a plugin for jQuery UI that works in a similar way to Draggable and Resizable.
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.
#### CDN
``html
`
or
npm install --save jquery-ui-rotatable
`
$3
Somewhere in your HTML ...
html
`
Rotate me!
.rotatable()
Options that can be set when you call are:
angle
* : __the starting rotation for the element (deprecated in favor of radians and degrees)__
degrees
* : starting rotation in degrees (default 0)
handle
* : url to a custom image for the handle
handleOffset
* : offset in format {top: 0, left: 0} for where the handle should be placed
radians
* : starting rotation in radians (default 0)
rotationCenterOffset
* : offset in format {top: 0, left: 0} to the center of rotation
snap
* : snaps to step in degrees (default: false)
step
* : an angle in degrees that the rotation will snap to if the shift key is held (default 22.5°)
start
* , stop, rotate: callbacks when those events occur
transforms
* : an object with css transforms you would like to apply to the rotatable element (except "rotate"). They will be applied on each rotation (default: NULL)
wheelRotate
* : enable/disable mouse wheel to rotate element (default: true)
element
The start, rotate and stop callbacks provide the following in the ui argument of the callback:
* : The jQuery element being rotated.
angle
* : An object containing information about the rotation angle, with the following keys:
start
* : The angle at the beginning of the rotation.
current
* : The current angle of the rotation in radians.
degrees
* : The current angle of the rotation in degrees.
stop
* : The angle at the end of the rotation.
resizable()
Note that you should define a height and width for anything that you make rotatable, as the rotation happens around the center point of the element, and when you don't define these things, it could look and feel a little a strange. Alternatively, specify the center of rotation as mentioned earlier.
You can also combine this plugin with the jQuery UI built-in and draggable(), although the latter works best when applied to a container with the rotatable inside it. See the Demo page for some examples.
$('#target').rotatable('enable');
You can disable/enable the rotation using and $('#target').rotatable('disable');`.
Hovering over an element and rotating the scroll wheel (or equivalent) will cause the element to rotate.