The transitionTimingFunction
property gets and sets
the speed curve of the transition effect.
transitionTimingFunction |
Yes | 10 | Yes | Yes (WebkitTransitionTimingFunction) | Yes |
Return the transitionTimingFunction property:
var v = object.style.transitionTimingFunction
Set the transitionTimingFunction property:
object.style.transitionTimingFunction ='ease|linear|ease-in|ease-out|ease-in-out|cubic-bezier()|initial|inherit'
Default Value: | ease |
---|---|
Return Value: | A string representing the transition-timing-function property |
CSS Version | CSS3 |
The following code shows how to change the speed curve of a transition effect.
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {<!-- w w w . j a va2 s . c om-->
border: 1px solid black;
background-color: lightblue;
width: 270px;
height: 200px;
overflow: auto;
-webkit-transition: all 2s; /* For Safari 3.1 to 6.0 */
transition: all 2s;
}
#myDIV:hover {
background-color: coral;
width: 570px;
height: 500px;
padding: 100px;
border-radius: 50px;
}
</style>
</head>
<body>
<button onclick="myFunction()">test</button>
<div id="myDIV">hover me</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.WebkitTransitionTimingFunction = "linear"; // Code for Safari 3.1 to 6.0
document.getElementById("myDIV").style.transitionTimingFunction = "linear"; // Standard syntax
}
</script>
</body>
</html>
The code above is rendered as follows: