static_callbacks.html
7.48 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>jCarousel Examples</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
<!--
jQuery library
-->
<script type="text/javascript" src="../lib/jquery-1.4.2.min.js"></script>
<!--
jCarousel library
-->
<script type="text/javascript" src="../lib/jquery.jcarousel.min.js"></script>
<!--
jCarousel skin stylesheet
-->
<link rel="stylesheet" type="text/css" href="../skins/tango/skin.css" />
<style type="text/css">
/**
* Overwrite for having a carousel with dynamic width.
*/
.jcarousel-skin-tango .jcarousel-container-horizontal {
width: 85%;
}
.jcarousel-skin-tango .jcarousel-clip-horizontal {
width: 100%;
}
#display {
clear: both;
width: auto;
height: 250px;
overflow: scroll;
border: 1px solid #666;
background-color: #fcfcfc;
padding: 10px;
}
</style>
<script type="text/javascript">
/**
* This is the callback function which receives notification
* about the state of the next button.
*/
function mycarousel_buttonNextCallback(carousel, button, enabled) {
display('Next button is now ' + (enabled ? 'enabled' : 'disabled'));
};
/**
* This is the callback function which receives notification
* about the state of the prev button.
*/
function mycarousel_buttonPrevCallback(carousel, button, enabled) {
display('Prev button is now ' + (enabled ? 'enabled' : 'disabled'));
};
/**
* This is the callback function which receives notification
* right after initialisation of the carousel
*/
function mycarousel_initCallback(carousel, state) {
if (state == 'init')
display('Carousel initialised');
else if (state == 'reset')
display('Carousel reseted');
};
/**
* This is the callback function which receives notification
* right after reloading of the carousel
*/
function mycarousel_reloadCallback(carousel) {
display('Carousel reloaded');
};
/**
* This is the callback function which receives notification
* when an item becomes the first one in the visible range.
*/
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
display('Item #' + idx + ' is now the first item');
};
/**
* This is the callback function which receives notification
* when an item is no longer the first one in the visible range.
*/
function mycarousel_itemFirstOutCallback(carousel, item, idx, state) {
display('Item #' + idx + ' is no longer the first item');
};
/**
* This is the callback function which receives notification
* when an item becomes the first one in the visible range.
*/
function mycarousel_itemLastInCallback(carousel, item, idx, state) {
display('Item #' + idx + ' is now the last item');
};
/**
* This is the callback function which receives notification
* when an item is no longer the first one in the visible range.
*/
function mycarousel_itemLastOutCallback(carousel, item, idx, state) {
display('Item #' + idx + ' is no longer the last item');
};
/**
* This is the callback function which receives notification
* when an item becomes the first one in the visible range.
* Triggered before animation.
*/
function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
// No animation on first load of the carousel
if (state == 'init')
return;
jQuery('img', item).fadeIn('slow');
};
/**
* This is the callback function which receives notification
* when an item becomes the first one in the visible range.
* Triggered after animation.
*/
function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
display('Item #' + idx + ' is now visible');
};
/**
* This is the callback function which receives notification
* when an item is no longer the first one in the visible range.
* Triggered before animation.
*/
function mycarousel_itemVisibleOutCallbackBeforeAnimation(carousel, item, idx, state) {
jQuery('img', item).fadeOut('slow');
};
/**
* This is the callback function which receives notification
* when an item is no longer the first one in the visible range.
* Triggered after animation.
*/
function mycarousel_itemVisibleOutCallbackAfterAnimation(carousel, item, idx, state) {
display('Item #' + idx + ' is no longer visible');
};
/**
* Helper function for printing out debug messages.
* Not needed for jCarousel.
*/
var row = 1;
function display(s) {
// Log to Firebug (getfirebug.com) if available
//if (window.console != undefined && typeof window.console.log == 'function')
// console.log(s);
if (row >= 1000)
var r = row;
else if (row >= 100)
var r = ' ' + row;
else if (row >= 10)
var r = ' ' + row;
else
var r = ' ' + row;
jQuery('#display').html(jQuery('#display').html() + r + ': ' + s + '<br />').get(0).scrollTop += 10000;
row++;
};
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
scroll: 1,
initCallback: mycarousel_initCallback,
reloadCallback: mycarousel_reloadCallback,
buttonNextCallback: mycarousel_buttonNextCallback,
buttonPrevCallback: mycarousel_buttonPrevCallback,
itemFirstInCallback: mycarousel_itemFirstInCallback,
itemFirstOutCallback: mycarousel_itemFirstOutCallback,
itemLastInCallback: mycarousel_itemLastInCallback,
itemLastOutCallback: mycarousel_itemLastOutCallback,
itemVisibleInCallback: {
onBeforeAnimation: mycarousel_itemVisibleInCallbackBeforeAnimation,
onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation
},
itemVisibleOutCallback: {
onBeforeAnimation: mycarousel_itemVisibleOutCallbackBeforeAnimation,
onAfterAnimation: mycarousel_itemVisibleOutCallbackAfterAnimation
}
});
});
</script>
</head>
<body>
<div id="wrap">
<h1>jCarousel</h1>
<h2>Riding carousels with jQuery</h2>
<h3>Carousel illustrating the callback functions</h3>
<p>
This carousel has registered all available callback functions and displays
information about the state of the items and buttons. Additionally the width
of the carousel is set to auto. Resize the browser window and see what happens.
</p>
<ul id="mycarousel" class="jcarousel-skin-tango">
<li><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/75/199481072_b4a0d09597_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/57/199481087_33ae73a8de_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/77/199481108_4359e6b971_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/58/199481218_264ce20da0_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/69/199481255_fdfe885f87_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg" width="75" height="75" alt="" /></li>
<li><img src="http://static.flickr.com/70/229228324_08223b70fa_s.jpg" width="75" height="75" alt="" /></li>
</ul>
<p id="display"></p>
</div>
</body>
</html>