随机旋转后,如何使用旋转插件获得旋转角度



我试图在使用谷歌旋转插件时找到我的"旋转"对象落地的角度。这是我到目前为止的代码:

$('#spinnerButton a').bind('click', function(e) {
    var deg = 1500 + Math.round(Math.random()*1500);
    var rotation = function (){
       $("#spinImg").rotate({
          angle:0, 
          animateTo: deg,
          duration: 6000
       });
       console.log (deg);
    }
    e.preventDefault();
    rotation();
});

我可以得到它落地的学位。(高数字)但是我试图使用.getRotateAngle()无济于事。我尝试了设置为 7000 的回调,并尝试只使用 $(this).getRotateAngle();但同样,除了"0"的原始位置之外,什么都没有显示。

jsFiddle

  $("#image").rotate({
      bind: {
          click: function () {
              var deg = 1500 + Math.round(Math.random() * 1500);
              $("#image").rotate({
                  angle: 0,
                  animateTo: deg,
                  duration: 6000,
                  callback: function() {
                        alert( $(this).getRotateAngle() % 360 );
                  }
              });
          }
      }
  });

最新更新