繁体   English   中英

使用JQueryRotate逆时针旋转图像

[英]Rotate image counterclockwise with JQueryRotate

每当用户单击图像的父元素时,我都尝试将图像逆时针旋转180度。 我正在使用JQueryRotate v2.3。

我的代码:

$('.material').click(function () {              
    var thisPic = $(this).find('.fanpic');
    thisPic.rotate({ animateTo: -180 });;
});

首先可以使用,但是从第二次单击开始,图像开始顺时针旋转。 如何解决此问题,使图像始终逆时针旋转?

尝试将旋转值保持在例如父元素中的某个位置:

$('.material').click(function () {
    if(!this.animateTo) this.animateTo = 0;
    this.animateTo = this.animateTo + -180;
    var thisPic = $(this).find('.fanpic');
    thisPic.rotate({ animateTo: this.animateTo });;
});

试试这个jsfiddle

希望这可以帮助,

可以随角度保持变量。

var angle = -180;
$('.material').click(function () {              
    var thisPic = $(this).find('.fanpic');
    thisPic.rotate({ animateTo: angle });
    angle -= 180;
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM