最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - event listener, one css transform ends and another is started - Stack Overflow

programmeradmin3浏览0评论

I have a css transform that happens when a button is clicked shown here /

I'm not sure if this possible but, would it be possible to make a event listener or perhaps there's a different method, so when that button is clicked and the transform is plete another class replaces that transform class that just finished and makes a second animation. I want to avoid using keyframe animation because I'm having an issue with that particular method where I want to use the end state of the animation for a transform, but it resets. You can see that issue here /

Basically I'd like the animation to run it's course (it's two step), finish, and then be able to click another button to have other transforms happen. Like here / except the starting transform is only one step.

I have a css transform that happens when a button is clicked shown here http://jsfiddle/xCkX7/5/

I'm not sure if this possible but, would it be possible to make a event listener or perhaps there's a different method, so when that button is clicked and the transform is plete another class replaces that transform class that just finished and makes a second animation. I want to avoid using keyframe animation because I'm having an issue with that particular method where I want to use the end state of the animation for a transform, but it resets. You can see that issue here http://jsfiddle/xCkX7/23/

Basically I'd like the animation to run it's course (it's two step), finish, and then be able to click another button to have other transforms happen. Like here http://jsfiddle/xCkX7/21/ except the starting transform is only one step.

Share Improve this question asked Mar 14, 2012 at 16:04 loriensleafsloriensleafs 2,2659 gold badges37 silver badges71 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The transitionend event fires whenever a CSS transition finishes. You can listen for that event from your first transition and then start the second transition when that event fires.

Keep in mind that there are vendor-specific prefixes on the transitionend event name in some browsers.

What you could do in this case is the follow sequence:

  1. Button is clicked
  2. Add event listender for transitionend event on the target object
  3. Make change that starts the first transition
  4. When transitionend event fires, remove event listener to you don't get confused with other transitions ending
  5. Make change that starts the second transition

You can see a working version of multi-stage transitions here: http://jsfiddle/jfriend00/5FnwY/

发布评论

评论列表(0)

  1. 暂无评论