run keyframes-animation on click more than once

只谈情不闲聊 提交于 2020-02-16 05:22:21

问题


i have a div that it have image content .i wanna implement animation when i click in image but it do only with first click and next click in image is Ineffective.what is problem and how can i solve it?

$(function () {
         $('div.c').bind('mousedown', function () {
             var $elem = $(this);
             $elem.stop(true)
             .css({ "-webkit-animation-name": "xi",
             "-webkit-animation-duration": "3s",
             "-webkit-animation-timing-function": "ease", 
             "-webkit-animation-delay": "1s",            
              })
              })})

and

     @-webkit-keyframes xi{ 0% {
  left: 100px;
}

40% {
  left: 150px;
}

60% {
  left: 75px;
}

100% {
  left: 100px;
}}

回答1:


You could reset your animation with a second keyframe block as suggested here: Css and jQuery: How do I trigger the repositioning of a CSS3-animated element back to where it was before the animation?

Here's also a possible solution on how to reset your animation when it's completed: Is there a callback on completion of a CSS3 animation?



来源:https://stackoverflow.com/questions/11279646/run-keyframes-animation-on-click-more-than-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!