-
Notifications
You must be signed in to change notification settings - Fork 23
/
basic-opacity.html
64 lines (57 loc) · 1.71 KB
/
basic-opacity.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>tram.js example</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="../support/styles/example.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../node_modules/jquery/dist/jquery.min.js"><\/script>')</script>
<script src="../dist/tram.js"></script>
</head>
<body>
<p>
Basic example of an opacity fade. Hover or tap the boxes.
</p>
<div class="row">
<div class="test wide"></div>
<div class="test wide"></div>
</div>
<div class="row">
<div class="test wide"></div>
<div class="test wide"></div>
</div>
<div class="row">
<div class="test wide"></div>
<div class="test wide"></div>
</div>
<script>
var $el = $('.test');
// intro fade in + callback
tram($el)
.add('opacity 1s ease-in-out')
.set({ opacity: 0 })
.start({ opacity: 1 })
.then(function () {
console.log('done!');
});
// element on / off events
function toggle(instance, opt, state) {
instance
.add('opacity ' + opt)
.start({ opacity: state ? 0.2 : 1 });
}
var touch = 'ontouchstart' in window;
$el.each(function (i, el) {
var instance = tram(el);
$(el).on(touch ? 'touchstart' : 'mouseover', function () {
toggle(instance, '0 ease-out-quint', true);
});
$(el).on(touch ? 'touchend' : 'mouseout', function () {
toggle(instance, '800 ease-in-out', false);
});
});
</script>
</body>
</html>