Monitoring CSS3 Animation End Event-webkitanimationend

Source: Internet
Author: User

When CSS3 's animation finishes an animation, we want to keep the animation in the terminating state or some other event, what do we do?

We can listen to the Webkitanimationend event,

// event at end of animation function () {    console.log ("End of Animation");})

-webkit-animation animations have three events:

Start Event: Webkitanimationstart
End Event: Webkitanimationend
Repeat motion event: webkitanimationiteration

// event at start of animation function () {    console.log ("animation start");}) // animations Repeat motion when events function () {    console.log ("animation repeats Motion");}) // event at end of animation function () {    console.log ("End of Animation");})

Example:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metahttp-equiv= "X-ua-compatible"content= "Ie=edge,chrome=1"><title>Webkitanimationend</title><styletype= "Text/css">#div1{margin:200px Auto 0;width:200px;Height:200px;Color:#fff;Background-color:#000;-webkit-animation:Transform 3s 2 ease;}@-webkit-keyframes Transform{0%{-webkit-transform:Scale (1) rotate (50deg);    }30%{-webkit-transform:Scale (2) rotate (100deg);    }6%{-webkit-transform:Scale (0.5) rotate ( -100deg);    }100%{-webkit-transform:Scale (1) rotate (0);    }}</style></Head><Body><DivID= "Div1"></Div><Scripttype= "Text/javascript">varo=document.getElementById ("Div1");//event at start of animationO.addeventlistener ("Webkitanimationstart", function() {alert ("Animation Start");})//animations Repeat motion when eventsO.addeventlistener ("webkitanimationiteration", function() {alert ("Animation Repeat Motion");})//event at end of animationO.addeventlistener ("Webkitanimationend", function() {     This. ClassName= ""; Alert ("End of animation");})</Script></Body></HTML>

CSS3 the Transition property transition, at the end of the animation, there is also an end event: webkittransitionend

Note: Transition only has this one event

Monitoring CSS3 Animation End Event-webkitanimationend

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.