/
index.html
123 lines (98 loc) · 3.05 KB
/
index.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Catepilla</title>
<style>
body {
font-family: sans-serif;
}
#pic {
height: 400px;
border: 1px solid #CCC;
width: 800px;
}
.catepilla {
position: relative;
}
.catepilla .segment {
position: absolute;
overflow: hidden;
}
.catepilla .segment img {
position: absolute;
}
</style>
<script src="modernizr.js"></script>
</head>
<body>
<h1>Catepilla</h1>
<p>
Make that image gallery get all wiggly<br />
<a href="http://github.com/nclud/catepilla">github.com/nclud/catepilla</a>
</p>
<div id="controls">
<p>
<button id="stop">stopAnimation</button>
<button id="start">startAnimation</button>
<button id="show">show</button>
<button id="hide">hide</button>
<button id="next">next</button>
</p>
<p id="select-image">
Select image:
<button data-select-index="0">image 1</button>
<button data-select-index="1">image 2</button>
<button data-select-index="2">image 3</button>
<button data-select-index="3">image 4</button>
<button data-select-index="4">image 5</button>
<button data-select-index="5">image 6</button>
</p>
</div>
<ul id="pics">
<li><img src="http://farm5.staticflickr.com/4119/4858565412_483fc5822c_z.jpg"></li>
<li><img src="http://farm2.staticflickr.com/1170/5135053388_4f386692a3_z.jpg"></li>
<li><img src="http://farm5.staticflickr.com/4028/5134455355_530219749b_z.jpg"></li>
<li><img src="http://farm6.staticflickr.com/5286/5277461065_05b9fb1032_z.jpg"></li>
<li><img src="http://farm5.staticflickr.com/4122/4857944215_5c20f70987_z.jpg"></li>
<li><img src="http://farm6.staticflickr.com/5243/5278072258_ca7c7f3713_z.jpg"></li>
</ul>
<p><a href="http://www.flickr.com/photos/nasacommons">Photos from the NASA Commons</p>
<script src="request-animation-frame/requestanimationframe.js"></script>
<script src="catepilla.js"></script>
<script>
var cat;
function init() {
var pics = document.getElementById('pics')
cat = new Catepilla( pics, {
height: 400,
wiggleDelay: 2000
})
// simple methods
document.getElementById('stop').addEventListener( 'click', function() {
cat.stopAnimation()
}, false )
document.getElementById('start').addEventListener( 'click', function() {
cat.startAnimation()
}, false )
document.getElementById('show').addEventListener( 'click', function() {
cat.show()
}, false )
document.getElementById('hide').addEventListener( 'click', function() {
cat.hide()
}, false )
document.getElementById('next').addEventListener( 'click', function() {
cat.next()
}, false )
document.getElementById('select-image').addEventListener( 'click', function( event ) {
if ( event.target.nodeName.toLowerCase() !== 'button' ) {
return
}
var index = parseInt( event.target.getAttribute('data-select-index'), 10 );
cat.setSelectedIndex( index );
}, false )
}
window.addEventListener( 'DOMContentLoaded', init, false )
</script>
</body>
</html>