gpt4 book ai didi

javascript - 使用 JQueryRotate 逆时针旋转图像

转载 作者:行者123 更新时间:2023-12-03 10:57:48 25 4
gpt4 key购买 nike

每次用户单击图像的父元素时,我都会尝试将图像逆时针旋转 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

希望这有帮助,

关于javascript - 使用 JQueryRotate 逆时针旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28203240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com