88 lines
2.2 KiB
HTML
88 lines
2.2 KiB
HTML
<html>
|
|
<head>
|
|
<style>
|
|
.box {
|
|
position: relative;
|
|
left: 0;
|
|
height: 100px;
|
|
width: 100px;
|
|
margin: 10px;
|
|
background-color: blue;
|
|
transform: translate(0);
|
|
transition-property: transform;
|
|
transition-duration: 0.5s;
|
|
}
|
|
|
|
.box1 {
|
|
transform: translate(50px);
|
|
}
|
|
|
|
.box2 {
|
|
transform: translate(50px) scale(1.05);
|
|
transition-duration: 0.55s;
|
|
}
|
|
|
|
.box3 {
|
|
transform: translate(0); /* same as default */
|
|
transition-duration: 0.3s;
|
|
}
|
|
|
|
.box4 {
|
|
transform: translate(100px);
|
|
transition-duration: 0.4s;
|
|
}
|
|
|
|
.box5 {
|
|
/* nothing */
|
|
}
|
|
|
|
</style>
|
|
<script src="transition-end-event-helpers.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
var expectedEndEvents = [
|
|
// [property-name, element-id, elapsed-time, listen]
|
|
["transform", "box1", 0.5, false],
|
|
["transform", "box2", 0.55, false],
|
|
["transform", "box4", 0.4, false]
|
|
];
|
|
|
|
function transitionElement(index)
|
|
{
|
|
var boxes = document.body.getElementsByClassName('box');
|
|
boxes[index-1].className = "box box" + index;
|
|
}
|
|
|
|
function setupTest()
|
|
{
|
|
var boxes = document.body.getElementsByClassName('box');
|
|
for (var i = 0; i < boxes.length; ++i) {
|
|
boxes[i].addEventListener("webkitTransitionEnd", recordTransitionEndEvent, false);
|
|
}
|
|
|
|
window.setTimeout(function() { transitionElement(1); }, 100);
|
|
window.setTimeout(function() { transitionElement(2); }, 150);
|
|
window.setTimeout(function() { transitionElement(3); }, 200);
|
|
window.setTimeout(function() { transitionElement(4); }, 50);
|
|
window.setTimeout(function() { transitionElement(5); }, 150);
|
|
}
|
|
|
|
runTransitionTest(expectedEndEvents, setupTest);
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
<p>Initiating transitions on transform properties of all boxes, starting at different times and with different durations and values.</p>
|
|
|
|
<div id="container">
|
|
<div id="box1" class="box"></div>
|
|
<div id="box2" class="box"></div>
|
|
<div id="box3" class="box"></div>
|
|
<div id="box4" class="box"></div>
|
|
<div id="box5" class="box"></div>
|
|
</div>
|
|
|
|
<div id="result"></div>
|
|
|
|
</body>
|
|
</html> |