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 Object
The HTML DOM TransitionEvent Object represents an event which incurs on a transition.
Here, “TransitionEvent” can have the following properties and methods −
| Property/Method |
Description |
|---|---|
| propertyName |
Itreturns returns astring corresponding to a CSS property used for transition when atransition event is triggered |
| elapsedTime |
Itreturns a numbercorresponding to how many seconds a transition had run when atransition event is triggered |
| pseudoElement |
Itreturns a nameof the pseudo-element of the transition |
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