Animation events: animationend Example

Size
2,939 Kb
Views
6,072

How do I make an animation events: animationend example?

For my blog article http://diessica.com/blog/posts/manipulacao-transicao-animacao-javascript.html. What is a animation events: animationend example? How do you make a animation events: animationend example? This script and codes were developed by Diéssica Gurskas on 10 January 2023, Tuesday.

Animation events: animationend Example Previews

Animation events: animationend Example - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Animation events: animationend Example</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans'> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ #foo { width: 200px; height: 200px; margin: auto; background: #3498db; border-radius: 10%;
}
.old { animation: rotate 2s ease; }
.new { animation: colors 3s; }
@keyframes rotate { 30% { transform: rotateY(180deg) rotate(-180deg); } 70% { transform: rotateY(270deg) rotate(180deg); }
}
@keyframes colors { 10% { background: yellow; } 30% { background: green; } 50% { background: red; } 70% { background: black; } 100% { background: purple; transform: rotate(360deg); }
}
/* não é importante */
body { font-family: 'Open Sans'; color: #fff; width: 450px; margin: 100px auto; text-align: center; background: #2c3e50;
}
pre { background: rgba(0,0,0,0.5); padding: 5px; display: inline-block; font-size: 15px;
}
.msg { margin-top: 25px; background: rgba(0,0,0,0.5); padding: 10px; color: #fff; border-radius: 5px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1>Animation events <pre>animationend</pre></h1>
<div id="foo" class="old"></div> <script src="js/index.js"></script>
</body>
</html>

Animation events: animationend Example - Script Codes CSS Codes

#foo { width: 200px; height: 200px; margin: auto; background: #3498db; border-radius: 10%;
}
.old { animation: rotate 2s ease; }
.new { animation: colors 3s; }
@keyframes rotate { 30% { transform: rotateY(180deg) rotate(-180deg); } 70% { transform: rotateY(270deg) rotate(180deg); }
}
@keyframes colors { 10% { background: yellow; } 30% { background: green; } 50% { background: red; } 70% { background: black; } 100% { background: purple; transform: rotate(360deg); }
}
/* não é importante */
body { font-family: 'Open Sans'; color: #fff; width: 450px; margin: 100px auto; text-align: center; background: #2c3e50;
}
pre { background: rgba(0,0,0,0.5); padding: 5px; display: inline-block; font-size: 15px;
}
.msg { margin-top: 25px; background: rgba(0,0,0,0.5); padding: 10px; color: #fff; border-radius: 5px;
}

Animation events: animationend Example - Script Codes JS Codes

// percorre cada evento como parâmetro da função endAnimation para funcionar no IE10, FF e webkit browsers sem repetir o método
["animationend", "webkitAnimationEnd"].forEach(function(endAnimation) { var foo = document.getElementById('foo'); // assiste a animação do elemento para disparar e executar a função foo.addEventListener(endAnimation, newClass, false);
});
// adiciona uma nova classe ao elemento, substituindo a anterior
function newClass() { // dispara mensagem ao término de cada animação this.insertAdjacentHTML('afterend', "<div class='msg'>Uma animação terminou.</div>"); // adiciona nova classe, substituindo a anterior this.className = "new";
}
Animation events: animationend Example - Script Codes
Animation events: animationend Example - Script Codes
Home Page Home
Developer Diéssica Gurskas
Username diessica
Uploaded January 10, 2023
Rating 3
Size 2,939 Kb
Views 6,072
Do you need developer help for Animation events: animationend Example?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Diéssica Gurskas (diessica) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!