2014-11-04 66 views
0
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); 

我有一个页面使用jQuery UI的旋转的插件jQuery UI的旋转GET旋转程度,当它停止

我的问题是怎样才能得到用户的旋转程度,当它停下来?

;

https://github.com/godswearhats/jquery-ui-rotatable

回答

2

根据您链接的页面(例如,如果用户旋转格30度,警报(30)。):

开始,旋转和停止回调在回调的ui参数中提供以下内容:

...

  • 角度:包含有关旋转角度的信息,与以下项的对象:

    ...

    • 站:在旋转结束时的角度。

因此,你可以阅读ui.angle.stop最终角(弧度)的stop回调中:

stop: function(event, ui) { 
    alert(ui.angle.stop); 
}, 

要将值转换为度,你可以简单地做ui.angle.stop/Math.PI * 180