使用prev和next点击动画CSS3旋转

时间:2014-04-14 12:05:56

标签: javascript jquery css3 rotation transform

我有一个圆圈,当你在.next类上触发onclick时需要转换90度,单击时会转换为-90 degress .prev

我已经设法根据我自己的Google自己创建了以下代码!

 $('.next').on('click',function(e){

          $('.object').animate({textIndent: 90}, {
            step: function(now,fx) {
              $(this).css('-webkit-transform','rotate('+now+'deg)').css('-moz-transform','rotate('+now+'deg)').css('transform','rotate('+now+'deg)');
            },
            duration:2000
          },'linear');

        });

        $('.prev').on('click',function(e){

          $('.object').animate({textIndent: 0}, {
            step: function(now,fx) {
              $(this).css('-webkit-transform','rotate('+now+'deg)').css('-moz-transform','rotate('+now+'deg)').css('transform','rotate('+now+'deg)');
            },
            duration:2000
          },'linear');

        });

到目前为止只需点击一下即可使用!但是我需要它旋转180,如果你在.next上点击两次,当你在.prev上点击4次时就像360一样。

但我似乎无法让它工作,这就是为什么我现在转向你的专家:)

1 个答案:

答案 0 :(得分:1)

您需要增量轮换。

我认为这个主题有一些很好的提示:

45 degree rotation increment on click w/out using variable

相关问题