Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM TransitionEvent elapsedTime Property
The HTML DOM TransitionEvent elapsedTime property returns a number corresponding to how many seconds a transition had run when a transition event is triggered.
Following is the syntax −
Returning number of seconds a transition has run −
transitionEvent.elapsedTime
Let us see an example of TransitionEvent elapsedTime property −
Example
<!DOCTYPE html>
<html>
<head>
<title>TransitionEvent elapsedTime</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
#playArea {
display: inline-block;
border-radius: 50%;
background-color: #DC3545;
width: 50px;
height: 50px;
border: 3px solid #AC3509;
transition: all 1.3s ease;
}
#playArea:hover {
transform:translateX(80px);
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>TransitionEvent-elapsedTime</legend>
<div id="playArea"></div>
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var playDisplay = document.getElementById("playArea");
function getElapsedTime(event) {
divDisplay.textContent = 'Elapsed Time in Transition: '+event.elapsedTime+' seconds';
}
playDisplay.addEventListener("transitionend", getElapsedTime);
</script>
</body>
</html>
Output
Before hovering over the div element −

After hovering over the div element −

Advertisements