Reputation: 2564
var params = {
// Callback fired on rotation start.
start: function(event, ui) {
},
// Callback fired during rotation.
rotate: function(event, ui) {
},
// Callback fired on rotation end.
stop: function(event, ui) {
//Need to get rotate degree
},
};
$('#target').rotatable(params);
I have a page use jquery-ui-rotatable plugin
My question is how can I get user's rotate degree when it stop?
(ex. if user rotate the div 30 degree, alert(30);)
https://github.com/godswearhats/jquery-ui-rotatable
Upvotes: 0
Views: 1140
Reputation: 115940
According to the page you've linked:
The start, rotate and stop callbacks provide the following in the ui argument of the callback:
...
angle: An object containing information about the rotation angle, with the following keys:
...
- stop: The angle at the end of the rotation.
Thus, you can read the final angle (in radians) from ui.angle.stop
inside the stop
callback:
stop: function(event, ui) {
alert(ui.angle.stop);
},
To convert the value to degrees, you can simply do ui.angle.stop / Math.PI * 180
.
Upvotes: 2