javascript - Rotate with jQuery, remember position -


i'm rotating div in code bellow. problem don't know how make element continue last position when click again. how do that? (i able in way didn't work in ie)

jsfiddle

html:

<div class="square">click me</div> 

css:

.square {     background:red;     height:100px;     width:100px;     cursor:pointer; } 

js:

$('.square').click(function () {     rotate($(this), -180, 1000); });  function rotate(element, degrees, speed) {     element.animate({         borderspacing: degrees     }, {         duration: speed,         step: function (now, fx) {             $(this).css('-webkit-transform', 'rotate(' + + 'deg)');             $(this).css('-moz-transform', 'rotate(' + + 'deg)');             $(this).css('transform', 'rotate(' + + 'deg)');         }     }); } 

you can use jqueryrotator...

and use js code...

var value = 0 $("#image").rotate({     bind:       {          click: function(){             value +=90;             $(this).rotate({ animateto:value})         }     }     }); 

and working fiddle is... http://jsfiddle.net/se4xc/ hope work you.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -