How to rotate with Pixastic jquery more than once?

半世苍凉 提交于 2019-12-24 17:25:29

问题


I try to rotate my image when I click(using Pixastic) but I can only rotate 1 time, how can I go on rotating each time I click to the image

$('#tok').click(function() {
                $("#tok").pixastic("rotate", {angle:90});                   
            }); 

回答1:


I have NOT used Pixastic before. But, I believe, everytime the image is clicked , you have to increase the angle 90 .

First Click -> 90 
Second Click->180 
Third Click ->270
Fourth Click ->360
Fifth Click ->90..etc

Updated:

It seems Pixastic remove the image first and insert it again. That's why onClick handler is executed once. Change it to "live" and it will work.

$('#tok').live('click',function() {
     $(this).pixastic("rotate", {angle:90});                 
});

Check Demo : here.




回答2:


If you want to rotate it finer than 90 degree, you could also use the HTML5 range Element (or a workaround for deprecated browsers ( like IE 9 and below ;-) )

HTML (5)

<input type="range" id="rotate" min="-180" max="180" value="0" step="1">

jQuery

$('.rotate').live('change', function(){
    $('img').pixastic("rotate", {angle: $(this).val() });
}

Kind regards to Jacob Seidelin for his great plugin!



来源:https://stackoverflow.com/questions/7723729/how-to-rotate-with-pixastic-jquery-more-than-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!