【问题标题】:cannot repeat animation - jQuery不能重复动画 - jQuery
【发布时间】:2012-07-19 17:26:12
【问题描述】:

我无法使用以下示例重复动画(使用jQuery Transit

$("#rotateDiv2").button().click(function() {
    $('#second').transition({
        perspective: '100px',
        easing: 'snap',
        duration: '3000ms',
        rotate3d: '1, 1, 0, 360deg'
    });
});

它确实有效,只有效一次(当然是在单击按钮时)。第二次我点击它什么都不做。谢谢!!

【问题讨论】:

    标签: jquery jquery-plugins css jquery-animate css-transitions


    【解决方案1】:

    您可以在回调中重置 CSS 转换属性:

    http://jsfiddle.net/zA2ZQ/2/

    $("#rotateDiv2").button().click(function() {
        $('#second').transition({
            perspective: '100px',
            easing: 'snap',
            duration: '3000ms',
            rotate3d: '1, 1, 0, 360deg'
        }, function(){
          //reset the transform property
          $(this).css('transform', '');
        });
    });​
    

    【讨论】:

    • 它有效,只是它重置了属性并且它有点问题导致div是可拖动和可调整大小的,重置后它会返回到起点。如果没有其他解决方法,我应该保留最后一个属性 > 重置 > 恢复属性吗?这是怎么做到的?
    • 只是重置转换属性似乎可以做到(更新答案)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多