-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.js
More file actions
252 lines (181 loc) · 6.84 KB
/
Copy pathscript.js
File metadata and controls
252 lines (181 loc) · 6.84 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
/* Author:
Anthony Armstrong
*/
// make sure you use document.ready and not window.load
$(document).ready(function() {
/*
see home.php for 'div.backgrounds', the selector for the plugin
should always be the parent wrapper of the images/content
*/
var slides = $('div.backgrounds');
slides.stretcharmstrong({
'rotate' : true,
'rotate_interval' : 5000,
'transition' : {
'type' : 'fade',
'duration' : 1500,
'orientation' : 'horizontal'
},
'element' : 'img',
'resize' : true,
'background' : true,
'weighted' : false,
'loading_element' : '.loading-overlay',
transition_complete : function(event) { // some properties for the transition...
console.log(this); // the image that has been transitioned in...
console.log(event);
console.log('transition complete');
},
cycle_complete : function() {
console.log('cycle complete');
},
rotate_changed : function(event) { // info on the state of rotation
console.log(event);
if (event.rotate == 'resumed') {
$('.timer-ctl').text('pause');
$('.timer-ctl').removeClass('resume');
$('.timer-ctl').addClass('pause');
}
if (event.rotate == 'paused') {
$('.timer-ctl').text('resume');
$('.timer-ctl').removeClass('pause');
$('.timer-ctl').addClass('resume');
}
},
on_resize : function(event) {
console.log($(this));
console.log(event.dimensions.width + ', ' + event.dimensions.height);
}
});
var inline = $('div.inline-content');
inline.stretcharmstrong({
'rotate' : true,
'rotate_interval' : 3000,
'transition' : {
'type' : 'slide',
'duration' : 1500,
'orientation' : 'vertical'
},
'weighted' : false,
'element' : 'img',
'resize' : true,
'background' : false,
transition_complete : function(event) { // some properties for the transition...
console.log(this); // the image that has been transitioned in...
console.log(event);
console.log('transition complete');
},
cycle_complete : function() {
console.log('cycle complete');
},
rotate_changed : function(event) { // info on the state of rotation
console.log(event);
},
on_resize : function(event) {
console.log($(this));
console.log(event.dimensions.width + ', ' + event.dimensions.height);
}
});
/*
see home.php for markup, these controls will show the next and
previous images/contents
*/
$('#next').bind('click', function(e) {
e.preventDefault();
// call 'next' function
slides.stretcharmstrong('next');
});
$('#prev').bind('click', function(e) {
e.preventDefault();
// call 'prev' function
slides.stretcharmstrong('prev');
});
$('.pause').live('click', function(e) {
e.preventDefault();
// call 'pause' function
slides.stretcharmstrong('pause');
});
$('.resume').live('click', function(e) {
e.preventDefault();
// call 'resume' function
slides.stretcharmstrong('resume');
});
slides.find('img').each(function(i) {
$('div.slide-chooser').append('<a href="#" title="Show slide '+i+'" id="'+i+'">'+i+'</a>');
});
$('div.slide-chooser a').bind('click', function(e) {
e.preventDefault();
slides.stretcharmstrong('jumpto', parseInt($(this).attr('id')));
});
/* middle controls */
$('section.middle a.next').bind('click', function(e) {
e.preventDefault();
// call 'next' function
inline.stretcharmstrong('next');
});
$('section.middle a.prev').bind('click', function(e) {
e.preventDefault();
// call 'prev' function
inline.stretcharmstrong('prev');
});
/* instance controls */
$('.destroy').live('click', function(e) {
e.preventDefault();
// destroy instance
slides.stretcharmstrong('destroy', false);
$('.instance-ctl').text('init');
$('.instance-ctl').removeClass('destroy');
$('.instance-ctl').addClass('init');
});
$('.init').live('click', function(e) {
e.preventDefault();
// inject images into wrapper
slides.append($('<img src="/assets/img/01.jpg" alt="An Image" />'));
slides.append($('<img src="/assets/img/02.jpg" alt="An Image" />'));
slides.append($('<img src="/assets/img/03.jpg" alt="An Image" />'));
slides.append($('<img src="/assets/img/04.jpg" alt="An Image" />'));
slides.append($('<img src="/assets/img/05.jpg" alt="An Image" />'));
// re-init instance
slides.stretcharmstrong({
'rotate' : true,
'rotate_interval' : 5000,
'transition' : {
'type' : 'fade',
'duration' : 1500,
'orientation' : 'horizontal'
},
'element' : 'img',
'resize' : true,
'background' : true,
'loading_element' : '.loading-overlay',
transition_complete : function(event) { // some properties for the transition...
console.log(this); // the image that has been transitioned in...
console.log(event);
console.log('transition complete');
},
cycle_complete : function() {
console.log('cycle complete');
},
rotate_changed : function(event) { // info on the state of rotation
console.log(event);
if (event.rotate == 'resumed') {
$('.timer-ctl').text('pause');
$('.timer-ctl').removeClass('resume');
$('.timer-ctl').addClass('pause');
}
if (event.rotate == 'paused') {
$('.timer-ctl').text('resume');
$('.timer-ctl').removeClass('pause');
$('.timer-ctl').addClass('resume');
}
},
on_resize : function(event) {
console.log($(this));
console.log(event.dimensions.width + ', ' + event.dimensions.height);
}
});
$('.instance-ctl').text('destroy');
$('.instance-ctl').removeClass('init');
$('.instance-ctl').addClass('destroy');
});
});