【问题标题】:Jquery .click wait until transition endsJquery .click 等到过渡结束
【发布时间】:2014-05-03 04:30:43
【问题描述】:

如果元素当前正在旋转,有谁知道如何停止 .click 函数的工作。

$(".right").click(function(e) {

  angle1 = getRotationDegrees($('.circle'));//find current rotation angle
  newrot = angle1-90;//take 90 degrees from current rotation

  if($('.circle').is(':animated')) return;

  $('.circle').transition({ rotate: newrot+'deg',
    duration: 500  });   
});

【问题讨论】:

标签: jquery


【解决方案1】:

您可以在元素旋转时取消绑定事件:

$(".right").unbind( "click" );

如果元素完成旋转,则再次绑定点击事件。

【讨论】:

  • 我将如何使用 bind 和 unbind 重构它?
【解决方案2】:

一个简单的解决方案是在再次执行 transition 之前检查 currentAngle % 90 == 0 是否存在。

我认为:animated 不起作用的问题是因为transition (css)jQuery animations 不同,因此:animated 不是由转换携带的。

【讨论】:

    猜你喜欢
    • 2012-03-04
    • 1970-01-01
    • 2017-04-13
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    相关资源
    最近更新 更多