forked from ai/transition-events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
107 lines (104 loc) · 3.62 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>jQuery Transition Events Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="lib/transition-events.js"></script>
<style>
#road {
position: relative;
width: 80%;
height: 5px;
margin: 200px auto 0 auto;
background: #ccc;
}
#road i {
display: inline-block;
position: absolute;
top: 10px;
padding-right: 5px;
border-right: 1px solid;
height: 20px;
color: green;
}
#road i.part {
color: black;
}
#bus {
width: 10px;
height: 10px;
background: blue;
position: absolute;
top: -35px;
left: 0;
-webkit-transition: left 2s linear;
-moz-transition: left 2s linear;
transition: left 2s linear;
}
#bus.at-home {
left: 100%;
}
#car {
width: 10px;
height: 10px;
background: red;
position: absolute;
top: -150px;
left: 0;
-webkit-transition-property: top, left;
-webkit-transition-delay: 0.5s, 0;
-webkit-transition-duration: 0.5s, 2s;
-webkit-transition-timing-function: linear;
-moz-transition-property: top, left;
-moz-transition-delay: 0.5s, 0;
-moz-transition-duration: 0.5s, 2s;
-moz-transition-timing-function: linear;
transition-property: top, left;
transition-delay: 0.5s, 0;
transition-duration: 0.5s, 2s;
transition-timing-function: linear;
}
#car.at-home {
top: -65px;
left: 100%;
}
</style>
</head>
<body>
<h1>jQuery Transition Events Test</h1>
<p>
Support: <b id="support"></b>.
Event name: <b id="event"></b>.
</p>
<div id="road">
<div id="car"></div>
<div id="bus"></div>
</div>
<script>
jQuery(document).ready(function ($) {
$('#support').text(
$.Transitions.isSupported() ? 'Yes' : 'No');
$('#event').text($.Transitions.getEvent());
var road = $('#road');
var car = $('#car');
var height = 0;
var drawMark = function (e) {
var ms = (new Date()).getMilliseconds()
var text = e.propertyName + ' ' + e.elapsedTime + ' ' +
e.currentTarget.id + ' ' + e.type + ' ' + ms;
var width = road.width();
$('<i>').
text(text).
css('right', width - parseInt(car.css('left'))).
css('padding-top', height).
appendTo(road);
height += 25;
};
$('#car').transitionEnd(drawMark).addClass('at-home');
$('#bus').addClass('at-home').afterTransition(drawMark);
$('#car, #bus').afterTransition(0.5, drawMark);
});
</script>
</body>
</html>