簡體   English   中英

如何在關鍵幀動畫時禁用“單擊”/並在完成時啟用?

[英]How to disable "click" while keyframe animation / and enable when it finish?

我的 css Keyframe 動畫和 JavaScript 有沖突 - 這里是http://district52.ru

我想禁用我的“CRUZ”上的點擊功能 - 直到它進入最終位置。

如何禁用“單擊”直到關鍵幀停止? 然后啟用它?

PS:我不希望javascript函數在關鍵幀結束之前啟動!

謝謝你,奧斯卡。

我看過演示頁面,看起來您的關鍵幀動畫不是循環; 您可以通過簡單的 CSS3 過渡實現您想要的效果。 如果您使用 jQuery,您可以執行以下操作:

$("#cruz").on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function () {
   $(this).addClass("finished");
});
$("#cruz").click(function () {
    if ( !$(this).hasClass("finished") ) return;
    // Here goes the code that will execute if it's not animating
    // Remember to remove the class which you use as filter ("finished")
});

您還可以添加 CSS 規則來避免光標顯示“可點擊”圖標,如下所示:

#cruz {
    cursor: initial;
}
#cruz.finished {
    cursor: pointer;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM