get rotation Angle after rotation complete

10 views
Skip to first unread message

Eric Amidon

unread,
Sep 17, 2013, 4:28:37 PM9/17/13
to jquery...@googlegroups.com
I have set up a randomizer so that the rotation ends on a different point every time you click the button. The part I'm having difficulty with is finding the rotation angle upon completion of the rotate animation. Are there any examples out there that someone can link me too? Greatly appreciated.

Paweł Witkowski

unread,
Sep 17, 2013, 4:31:28 PM9/17/13
to jquery...@googlegroups.com
I think this example should help, If not please let me know:

 $("#img").rotate({
        angle
: 45,
        bind
: {
            click
: function(){
               alert
($(this).getRotateAngle());
           
}
       
}
   
});


W dniu 17 września 2013 22:28 użytkownik Eric Amidon <ami...@gmail.com> napisał:
I have set up a randomizer so that the rotation ends on a different point every time you click the button. The part I'm having difficulty with is finding the rotation angle upon completion of the rotate animation. Are there any examples out there that someone can link me too? Greatly appreciated.

--
Otrzymujesz tę wiadomość, ponieważ subskrybujesz grupę dyskusyjną Google o nazwie „jQueryRotate”.
 
Aby anulować subskrypcję tej grupy i przestać otrzymywać z niej wiadomości, wyślij e-maila do jqueryrotate...@googlegroups.com.
Więcej opcji znajdziesz na https://groups.google.com/groups/opt_out



--
Pawel Witkowski
Senior JavaScript Developer / QML / Silverlight
webpage: http://wilq32.blogspot.com

Paweł Witkowski

unread,
Sep 17, 2013, 4:32:59 PM9/17/13
to jquery...@googlegroups.com

Eric Amidon

unread,
Sep 17, 2013, 4:46:38 PM9/17/13
to jquery...@googlegroups.com
I wind up getting a really large number and am unsure of the math to reveal the proper angle after so many spins. Here is my code so far:

$('#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,
              callback: function(){   alert($(this).getRotateAngle());
              }
           });

        }

        e.preventDefault();
        rotation();

    });

Paweł Witkowski

unread,
Sep 17, 2013, 5:05:43 PM9/17/13
to jquery...@googlegroups.com
Oh a large number might be true - just get this value and use rest from dividing:

value = value % 360


2013/9/17 Eric Amidon <ami...@gmail.com>

Eric Amidon

unread,
Sep 17, 2013, 5:15:58 PM9/17/13
to jquery...@googlegroups.com
Thank you so much. I appreciate your help. Now to build associative arrays of the different segments in 30 degree angles. :-)
Reply all
Reply to author
Forward
0 new messages