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)
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
Post a Comment