anything_slider-rails 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/anything_slider.gemspec +22 -0
- data/lib/anything_slider-rails.rb +7 -0
- data/lib/anything_slider/rails/engine.rb +6 -0
- data/lib/anything_slider/rails/version.rb +5 -0
- data/readme.markdown +57 -0
- data/vendor/assets/images/anythingslider/arrows-metallic.png +0 -0
- data/vendor/assets/images/anythingslider/arrows-minimalist.png +0 -0
- data/vendor/assets/images/anythingslider/construction.gif +0 -0
- data/vendor/assets/images/anythingslider/cs-portfolio.png +0 -0
- data/vendor/assets/images/anythingslider/default.png +0 -0
- data/vendor/assets/javascripts/anythingslider/jquery.anythingslider.fx.js +188 -0
- data/vendor/assets/javascripts/anythingslider/jquery.anythingslider.js +831 -0
- data/vendor/assets/javascripts/anythingslider/jquery.anythingslider.video.js +379 -0
- data/vendor/assets/javascripts/anythingslider/jquery.easing.1.3.js +205 -0
- data/vendor/assets/javascripts/anythingslider/swfobject.js +4 -0
- data/vendor/assets/stylesheets/anythingslider/animate.css +3813 -0
- data/vendor/assets/stylesheets/anythingslider/anythingslider-ie.css +65 -0
- data/vendor/assets/stylesheets/anythingslider/anythingslider.css.erb +202 -0
- data/vendor/assets/stylesheets/anythingslider/theme-construction.css.erb +142 -0
- data/vendor/assets/stylesheets/anythingslider/theme-cs-portfolio.css.erb +149 -0
- data/vendor/assets/stylesheets/anythingslider/theme-metallic.css.erb +146 -0
- data/vendor/assets/stylesheets/anythingslider/theme-minimalist-round.css.erb +144 -0
- data/vendor/assets/stylesheets/anythingslider/theme-minimalist-square.css.erb +144 -0
- metadata +107 -0
@@ -0,0 +1,379 @@
|
|
1
|
+
/*
|
2
|
+
* AnythingSlider Video Controller 1.3 beta for AnythingSlider v1.6+
|
3
|
+
* By Rob Garrison (aka Mottie & Fudgey)
|
4
|
+
* Dual licensed under the MIT and GPL licenses.
|
5
|
+
*/
|
6
|
+
(function($) {
|
7
|
+
$.fn.anythingSliderVideo = function(options){
|
8
|
+
|
9
|
+
//Set the default values, use comma to separate the settings, example:
|
10
|
+
var defaults = {
|
11
|
+
videoID : 'asvideo' // id prefix
|
12
|
+
};
|
13
|
+
|
14
|
+
return this.each(function(){
|
15
|
+
// make sure a AnythingSlider is attached
|
16
|
+
var video, tmp, service, sel, base = $(this).data('AnythingSlider');
|
17
|
+
if (!base) { return; }
|
18
|
+
video = base.video = {};
|
19
|
+
// Next update, I may just force users to call the video extension instead of it auto-running on window load
|
20
|
+
// then they can change the video options in that call instead of the base defaults, and maybe prevent the
|
21
|
+
// videos being initialized twice on startup (once as a regular video and second time with the API string)
|
22
|
+
video.options = $.extend({}, defaults, options);
|
23
|
+
|
24
|
+
// check if SWFObject is loaded
|
25
|
+
video.hasSwfo = (typeof(swfobject) !== 'undefined' && swfobject.hasOwnProperty('embedSWF') && typeof(swfobject.embedSWF) === 'function') ? true : false;
|
26
|
+
|
27
|
+
video.list = {};
|
28
|
+
video.hasVid = false;
|
29
|
+
video.hasEmbed = false;
|
30
|
+
video.services = $.fn.anythingSliderVideo.services;
|
31
|
+
video.len = 0; // used to add a unique ID to videos "asvideo#"
|
32
|
+
video.hasEmbedCount = 0;
|
33
|
+
video.hasiframeCount = 0;
|
34
|
+
video.$items = base.$items.filter(':not(.cloned)');
|
35
|
+
|
36
|
+
// find and save all known videos
|
37
|
+
for (service in video.services) {
|
38
|
+
if (typeof(service) === 'string') {
|
39
|
+
sel = video.services[service].selector;
|
40
|
+
video.$items.find(sel).each(function(){
|
41
|
+
tmp = $(this);
|
42
|
+
// save panel and video selector in the list
|
43
|
+
tmp.attr('id', video.options.videoID + video.len);
|
44
|
+
video.list[video.len] = {
|
45
|
+
id : video.options.videoID + video.len++,
|
46
|
+
panel : tmp.closest('.panel')[0],
|
47
|
+
service : service,
|
48
|
+
selector : sel,
|
49
|
+
status : -1 // YouTube uses -1 to mean the video is unstarted
|
50
|
+
};
|
51
|
+
video.hasVid = true;
|
52
|
+
if (sel.match('embed|object')) {
|
53
|
+
video.hasEmbed = true;
|
54
|
+
video.hasEmbedCount++;
|
55
|
+
} else if (sel.match('iframe')) {
|
56
|
+
video.hasiframeCount++;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
// Initialize each video, as needed
|
63
|
+
$.each(video.list, function(i,s){
|
64
|
+
// s.id = ID, s.panel = slider panel (DOM), s.selector = 'jQuery selector'
|
65
|
+
var tmp, $tar, vidsrc, opts,
|
66
|
+
$vid = $(s.panel).find(s.selector),
|
67
|
+
service = video.services[s.service],
|
68
|
+
api = service.initAPI || '';
|
69
|
+
// Initialize embeded video javascript api using SWFObject, if loaded
|
70
|
+
if (video.hasEmbed && video.hasSwfo && s.selector.match('embed|object')) {
|
71
|
+
$vid.each(function(){
|
72
|
+
// Older IE doesn't have an object - just make sure we are wrapping the correct element
|
73
|
+
$tar = ($(this).parent()[0].tagName === 'OBJECT') ? $(this).parent() : $(this);
|
74
|
+
vidsrc = ($tar[0].tagName === 'EMBED') ? $tar.attr('src') : $tar.find('embed').attr('src') || $tar.children().filter('[name=movie]').attr('value');
|
75
|
+
opts = $.extend(true, {}, {
|
76
|
+
flashvars : null,
|
77
|
+
params : { allowScriptAccess: 'always', wmode : base.options.addWmodeToObject, allowfullscreen : true },
|
78
|
+
attr : { 'class' : $tar.attr('class'), 'style' : $tar.attr('style'), 'data-url' : vidsrc }
|
79
|
+
}, service.embedOpts);
|
80
|
+
$tar.wrap('<div id="' + s.id + '"></div>');
|
81
|
+
// use SWFObject if it exists, it replaces the wrapper with the object/embed
|
82
|
+
swfobject.embedSWF(vidsrc + (api === '' ? '': api + s.id), s.id,
|
83
|
+
$tar.attr('width'), $tar.attr('height'), '10', null,
|
84
|
+
opts.flashvars, opts.params, opts.attr, function(){
|
85
|
+
// run init code if it exists
|
86
|
+
if (service.hasOwnProperty('init')) {
|
87
|
+
video.list[i].player = service.init(base, s.id, i);
|
88
|
+
}
|
89
|
+
if (i >= video.hasEmbedCount) {
|
90
|
+
base.$el.trigger('swf_completed', base); // swf callback
|
91
|
+
}
|
92
|
+
}
|
93
|
+
);
|
94
|
+
});
|
95
|
+
} else if (s.selector.match('iframe')) {
|
96
|
+
$vid.each(function(i,v){
|
97
|
+
vidsrc = $(this).attr('src');
|
98
|
+
tmp = (vidsrc.match(/\?/g) ? '' : '?') + '&wmode=' + base.options.addWmodeToObject; // string connector & wmode
|
99
|
+
$(this).attr('src', function(i,r){ return r + tmp + (api === '' ? '': api + s.id); });
|
100
|
+
});
|
101
|
+
}
|
102
|
+
});
|
103
|
+
|
104
|
+
// Returns URL parameter; url: http://www.somesite.com?name=hello&id=11111
|
105
|
+
// Original code from Netlobo.com (http://www.netlobo.com/url_query_string_javascript.html)
|
106
|
+
video.gup = function(n,s){
|
107
|
+
n = n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
|
108
|
+
var p = (new RegExp("[\\?&]"+n+"=([^&#]*)")).exec(s || window.location.href);
|
109
|
+
return (p===null) ? "" : p[1];
|
110
|
+
};
|
111
|
+
|
112
|
+
// postMessage to iframe - http://benalman.com/projects/jquery-postmessage-plugin/ (FOR IE7)
|
113
|
+
video.postMsg = function(data, vid){
|
114
|
+
var $vid = $('#' + vid);
|
115
|
+
if ($vid.length){
|
116
|
+
$vid[0].contentWindow.postMessage(data, $vid.attr('src').split('?')[0]);
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
// receive message from iframe
|
121
|
+
// no way to figure out which iframe since the message is from the window
|
122
|
+
video.message = function(e){
|
123
|
+
if (e.data) {
|
124
|
+
if (/infoDelivery/g.test(e.data)) { return; } // ignore youtube video loading spam
|
125
|
+
var data = $.parseJSON(e.data);
|
126
|
+
$.each(video.list, function(i,s){
|
127
|
+
if (video.services[video.list[i].service].hasOwnProperty('message')) {
|
128
|
+
video.services[video.list[i].service].message(base, data);
|
129
|
+
}
|
130
|
+
});
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
// toDO = 'cont', 'pause' or 'isPlaying'
|
135
|
+
video.control = function(toDo){
|
136
|
+
var i,
|
137
|
+
s = video.list,
|
138
|
+
slide = (toDo === 'pause') ? base.$lastPage[0] : base.$currentPage[0],
|
139
|
+
isPlaying = false;
|
140
|
+
for (i=0; i < video.len; i++){
|
141
|
+
if (s[i].panel === slide && video.services[s[i].service].hasOwnProperty(toDo)){
|
142
|
+
isPlaying = video.services[s[i].service][toDo](base, s[i].id, i);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
return isPlaying;
|
146
|
+
};
|
147
|
+
|
148
|
+
// iframe event listener
|
149
|
+
if (video.hasiframeCount){
|
150
|
+
if (window.addEventListener){
|
151
|
+
window.addEventListener('message', video.message, false);
|
152
|
+
} else { // IE
|
153
|
+
window.attachEvent('onmessage', video.message, false);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
// bind to events
|
158
|
+
base.$el
|
159
|
+
.bind('slide_init', function(){
|
160
|
+
video.control('pause');
|
161
|
+
})
|
162
|
+
.bind('slide_complete', function(){
|
163
|
+
video.control('cont');
|
164
|
+
});
|
165
|
+
|
166
|
+
base.options.isVideoPlaying = function(){ return video.control('isPlaying'); };
|
167
|
+
|
168
|
+
});
|
169
|
+
};
|
170
|
+
|
171
|
+
/* Each video service is set up as follows
|
172
|
+
* service-name : {
|
173
|
+
* // initialization
|
174
|
+
* selector : 'object[data-url*=service], embed[src*=service]', // required: jQuery selector used to find the video ('video' or 'iframe[src*=service]' are other examples)
|
175
|
+
* initAPI : 'string added to the URL to initialize the API', // optional: the string must end with a parameter pointing to the video id (e.g. "&player_id=")
|
176
|
+
* embedOpts : { flashvars: {}, params: {}, attr: {} }, // optional: add any required flashvars, parameters or attributes to initialize the API
|
177
|
+
* // video startup functions
|
178
|
+
* init : function(base, vid, index){ }, // optional: include any additional initialization code here; function called AFTER the embeded video is added using SWFObject
|
179
|
+
* // required functions
|
180
|
+
* cont : function(base, vid, index){ }, // required: continue play if video was previously played
|
181
|
+
* pause : function(base, vid, index){ }, // required: pause ALL videos
|
182
|
+
* message : function(base, data){ }, // required for iframe: process data received from iframe and update the video status for the "isPlaying" function
|
183
|
+
* isPlaying : function(base, vid, index){ } // required: return true if video is playing and return false if not playing (paused or ended)
|
184
|
+
* }
|
185
|
+
*
|
186
|
+
* Function variables
|
187
|
+
* base (object) = plugin base, all video values/functions are stored in base.video
|
188
|
+
* vid (string) is the ID of the video: vid = "asvideo1"; so jQuery needs a "#" in front... "#" + videoID option default ("asvideo") + index (e.g. "1"); each video matching a service will have a unquie vid
|
189
|
+
* index (number) is the unique video number from the vid (starts from zero)
|
190
|
+
*
|
191
|
+
* var list = base.video.list[index]; list will contain:
|
192
|
+
* list.id = vid
|
193
|
+
* list.service = service name (e.g. 'video', 'vimeo1', 'vimeo2', etc)
|
194
|
+
* list.selector = 'jQuery selector' (e.g. 'video', 'object[data-url*=vimeo]', 'iframe[src*=vimeo]', etc)
|
195
|
+
* list.panel = AnythingSlider panel DOM object. So you can target the video using $(list[index].panel).find(list[index].service) or $('#' + vid)
|
196
|
+
* list.status = video status, updated by the iframe event listeners added in the video service "ready" function; see examples below
|
197
|
+
*/
|
198
|
+
|
199
|
+
$.fn.anythingSliderVideo.services = {
|
200
|
+
|
201
|
+
// *** HTML5 video ***
|
202
|
+
video : {
|
203
|
+
selector : 'video',
|
204
|
+
cont : function(base, vid, index){
|
205
|
+
var $vid = $('#' + vid);
|
206
|
+
if ($vid.length && $vid[0].paused && $vid[0].currentTime > 0 && !$vid[0].ended) {
|
207
|
+
$vid[0].play();
|
208
|
+
}
|
209
|
+
},
|
210
|
+
pause : function(base, vid){
|
211
|
+
// pause ALL videos on the page
|
212
|
+
$('video').each(function(){
|
213
|
+
if (typeof(this.pause) !== 'undefined') { this.pause(); } // throws an error in older ie without this
|
214
|
+
});
|
215
|
+
},
|
216
|
+
isPlaying : function(base, vid, index){
|
217
|
+
var $vid = $('#' + vid);
|
218
|
+
// media.paused seems to be the only way to determine if a video is playing
|
219
|
+
return ($vid.length && typeof($vid[0].pause) !== 'undefined' && !$vid[0].paused && !$vid[0].ended) ? true : false;
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
// *** Vimeo iframe *** isolated demo: http://jsfiddle.net/Mottie/GxwEX/
|
224
|
+
vimeo1 : {
|
225
|
+
selector : 'iframe[src*=vimeo]',
|
226
|
+
initAPI : '&api=1&player_id=', // video ID added to the end
|
227
|
+
cont : function(base, vid, index){
|
228
|
+
if (base.options.resumeOnVisible && base.video.list[index].status === 'pause'){
|
229
|
+
// Commands sent to the iframe originally had "JSON.stringify" applied to them,
|
230
|
+
// but not all browsers support this, so it's just as easy to wrap it in quotes.
|
231
|
+
base.video.postMsg('{"method":"play"}', vid);
|
232
|
+
}
|
233
|
+
},
|
234
|
+
pause : function(base, vid){
|
235
|
+
// pause ALL videos on the page
|
236
|
+
$('iframe[src*=vimeo]').each(function(){
|
237
|
+
base.video.postMsg('{"method":"pause"}', this.id);
|
238
|
+
});
|
239
|
+
},
|
240
|
+
message : function(base, data){
|
241
|
+
// *** VIMEO *** iframe uses data.player_id
|
242
|
+
var index, vid = data.player_id || ''; // vid = data.player_id (unique to vimeo)
|
243
|
+
if (vid !== ''){
|
244
|
+
index = vid.replace(base.video.options.videoID, '');
|
245
|
+
if (data.event === 'ready') {
|
246
|
+
// Vimeo ready, add additional event listeners for video status
|
247
|
+
base.video.postMsg('{"method":"addEventListener","value":"play"}', vid);
|
248
|
+
base.video.postMsg('{"method":"addEventListener","value":"pause"}', vid);
|
249
|
+
base.video.postMsg('{"method":"addEventListener","value":"finish"}', vid);
|
250
|
+
}
|
251
|
+
// update current status - vimeo puts it in data.event
|
252
|
+
if (base.video.list[index]) { base.video.list[index].status = data.event; }
|
253
|
+
}
|
254
|
+
},
|
255
|
+
isPlaying : function(base, vid, index){
|
256
|
+
return (base.video.list[index].status === 'play') ? true : false;
|
257
|
+
}
|
258
|
+
},
|
259
|
+
|
260
|
+
// *** Embeded Vimeo ***
|
261
|
+
// SWFObject adds the url to the object data
|
262
|
+
// using param as a selector, the script above looks for the parent if it sees "param"
|
263
|
+
vimeo2 : {
|
264
|
+
selector : 'object[data-url*=vimeo], embed[src*=vimeo]',
|
265
|
+
embedOpts : { flashvars : { api : 1 } },
|
266
|
+
cont : function(base, vid, index) {
|
267
|
+
if (base.options.resumeOnVisible) {
|
268
|
+
var $vid = $('#' + vid);
|
269
|
+
// continue video if previously played & not finished (api_finish doesn't seem to exist) - duration can be a decimal number, so subtract it and look at the difference (2 seconds here)
|
270
|
+
if (typeof($vid[0].api_play) === 'function' && $vid[0].api_paused() && $vid[0].api_getCurrentTime() !== 0 && ($vid[0].api_getDuration() - $vid[0].api_getCurrentTime()) > 2) {
|
271
|
+
$vid[0].api_play();
|
272
|
+
}
|
273
|
+
}
|
274
|
+
},
|
275
|
+
pause : function(base, vid){
|
276
|
+
// find ALL videos and pause them, just in case
|
277
|
+
$('object[data-url*=vimeo], embed[src*=vimeo]').each(function(){
|
278
|
+
var el = (this.tagName === 'EMBED') ? $(this).parent()[0] : this;
|
279
|
+
if (typeof(el.api_pause) === 'function') {
|
280
|
+
el.api_pause();
|
281
|
+
}
|
282
|
+
});
|
283
|
+
},
|
284
|
+
isPlaying : function(base, vid, index){
|
285
|
+
var $vid = $('#' + vid);
|
286
|
+
return (typeof($vid[0].api_paused) === 'function' && !$vid[0].api_paused()) ? true : false;
|
287
|
+
}
|
288
|
+
},
|
289
|
+
|
290
|
+
// *** iframe YouTube *** isolated demo: http://jsfiddle.net/Mottie/qk5MY/
|
291
|
+
youtube1 : {
|
292
|
+
selector : 'iframe[src*=youtube]',
|
293
|
+
// "iv_load_policy=3" should turn off annotations on init, but doesn't seem to
|
294
|
+
initAPI : '&iv_load_policy=3&enablejsapi=1&playerapiid=',
|
295
|
+
cont : function(base, vid, index){
|
296
|
+
if (base.options.resumeOnVisible && base.video.list[index].status === 2){
|
297
|
+
base.video.postMsg('{"event":"command","func":"playVideo"}', vid);
|
298
|
+
}
|
299
|
+
},
|
300
|
+
pause : function(base, vid, index){
|
301
|
+
// pause ALL videos on the page - in IE, pausing a video means it will continue when next seen =(
|
302
|
+
$('iframe[src*=youtube]').each(function(){
|
303
|
+
// if (this.id !== vid || (this.id === vid && base.video.list[index].status >= 0)) { // trying to fix the continue video problem; this only breaks it
|
304
|
+
base.video.postMsg('{"event":"command","func":"pauseVideo"}', vid);
|
305
|
+
// }
|
306
|
+
});
|
307
|
+
},
|
308
|
+
message : function(base, data){
|
309
|
+
if (data.event === 'infoDelivery') { return; } // ignore youtube video loading spam
|
310
|
+
// *** YouTube *** iframe returns an embeded url (data.info.videoUrl) but no video id...
|
311
|
+
if (data.info && data.info.videoUrl) {
|
312
|
+
// figure out vid for youtube
|
313
|
+
// data.info.videoURL = http://www.youtube.com/watch?v=###########&feature=player_embedded
|
314
|
+
var url = base.video.gup('v', data.info.videoUrl), // end up with ###########, now find it
|
315
|
+
v = $('iframe[src*=' + url + ']'), vid, index;
|
316
|
+
// iframe src changes when watching related videos; so there is no way to tell which video has an update
|
317
|
+
if (v.length) {
|
318
|
+
vid = v[0].id;
|
319
|
+
index = vid.replace(base.video.options.videoID, '');
|
320
|
+
// YouTube ready, add additional event listeners for video status. BUT this never fires off =(
|
321
|
+
// Fixing this may solve the continue problem
|
322
|
+
if (data.event === 'onReady') {
|
323
|
+
base.video.postMsg('{"event":"listening","func":"onStateChange"}', vid);
|
324
|
+
}
|
325
|
+
// Update status, so the "isPlaying" function can access it
|
326
|
+
if (data.event === 'onStateChange' && base.video.list[index]) {
|
327
|
+
// update list with current status; data.info.playerState = YouTube
|
328
|
+
base.video.list[index].status = data.info.playerState;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}
|
332
|
+
},
|
333
|
+
isPlaying : function(base, vid, index){
|
334
|
+
var status = base.video.list[index].status;
|
335
|
+
// state: unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
|
336
|
+
return (status === 1 || status > 2) ? true : false;
|
337
|
+
}
|
338
|
+
},
|
339
|
+
|
340
|
+
// *** Embeded YouTube ***
|
341
|
+
// include embed for IE; SWFObject adds the url to the object data attribute
|
342
|
+
youtube2 : {
|
343
|
+
selector : 'object[data-url*=youtube], embed[src*=youtube]',
|
344
|
+
initAPI : '&iv_load_policy=3&enablejsapi=1&version=3&playerapiid=', // video ID added to the end
|
345
|
+
// YouTube - player states: unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
|
346
|
+
cont : function(base, vid, index) {
|
347
|
+
if (base.options.resumeOnVisible) {
|
348
|
+
var $vid = $('#' + vid);
|
349
|
+
// continue video if previously played and not cued
|
350
|
+
if ($vid.length && typeof($vid[0].getPlayerState) === 'function' && $vid[0].getPlayerState() > 0) {
|
351
|
+
$vid[0].playVideo();
|
352
|
+
}
|
353
|
+
}
|
354
|
+
},
|
355
|
+
pause : function(base, vid){
|
356
|
+
// find ALL videos and pause them, just in case
|
357
|
+
$('object[data-url*=youtube], embed[src*=youtube]').each(function(){
|
358
|
+
var el = (this.tagName === 'EMBED') ? $(this).parent()[0] : this;
|
359
|
+
// player states: unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
|
360
|
+
if (typeof(el.getPlayerState) === 'function' && el.getPlayerState() > 0) {
|
361
|
+
// pause video if not autoplaying (if already initialized)
|
362
|
+
el.pauseVideo();
|
363
|
+
}
|
364
|
+
});
|
365
|
+
},
|
366
|
+
isPlaying : function(base, vid){
|
367
|
+
var $vid = $('#' + vid);
|
368
|
+
return (typeof($vid[0].getPlayerState) === 'function' && ($vid[0].getPlayerState() === 1 || $vid[0].getPlayerState() > 2)) ? true : false;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
};
|
373
|
+
|
374
|
+
})(jQuery);
|
375
|
+
|
376
|
+
// Initialize video extension automatically
|
377
|
+
jQuery(window).load(function(){
|
378
|
+
jQuery('.anythingBase').anythingSliderVideo();
|
379
|
+
});
|
@@ -0,0 +1,205 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
3
|
+
*
|
4
|
+
* Uses the built in easing capabilities added In jQuery 1.1
|
5
|
+
* to offer multiple easing options
|
6
|
+
*
|
7
|
+
* TERMS OF USE - jQuery Easing
|
8
|
+
*
|
9
|
+
* Open source under the BSD License.
|
10
|
+
*
|
11
|
+
* Copyright © 2008 George McGinley Smith
|
12
|
+
* All rights reserved.
|
13
|
+
*
|
14
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
15
|
+
* are permitted provided that the following conditions are met:
|
16
|
+
*
|
17
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
18
|
+
* conditions and the following disclaimer.
|
19
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
20
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
21
|
+
* provided with the distribution.
|
22
|
+
*
|
23
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
24
|
+
* or promote products derived from this software without specific prior written permission.
|
25
|
+
*
|
26
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
27
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
29
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
32
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
33
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
34
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
*
|
36
|
+
*/
|
37
|
+
|
38
|
+
// t: current time, b: begInnIng value, c: change In value, d: duration
|
39
|
+
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
40
|
+
|
41
|
+
jQuery.extend( jQuery.easing,
|
42
|
+
{
|
43
|
+
def: 'easeOutQuad',
|
44
|
+
swing: function (x, t, b, c, d) {
|
45
|
+
//alert(jQuery.easing.default);
|
46
|
+
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
47
|
+
},
|
48
|
+
easeInQuad: function (x, t, b, c, d) {
|
49
|
+
return c*(t/=d)*t + b;
|
50
|
+
},
|
51
|
+
easeOutQuad: function (x, t, b, c, d) {
|
52
|
+
return -c *(t/=d)*(t-2) + b;
|
53
|
+
},
|
54
|
+
easeInOutQuad: function (x, t, b, c, d) {
|
55
|
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
56
|
+
return -c/2 * ((--t)*(t-2) - 1) + b;
|
57
|
+
},
|
58
|
+
easeInCubic: function (x, t, b, c, d) {
|
59
|
+
return c*(t/=d)*t*t + b;
|
60
|
+
},
|
61
|
+
easeOutCubic: function (x, t, b, c, d) {
|
62
|
+
return c*((t=t/d-1)*t*t + 1) + b;
|
63
|
+
},
|
64
|
+
easeInOutCubic: function (x, t, b, c, d) {
|
65
|
+
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
66
|
+
return c/2*((t-=2)*t*t + 2) + b;
|
67
|
+
},
|
68
|
+
easeInQuart: function (x, t, b, c, d) {
|
69
|
+
return c*(t/=d)*t*t*t + b;
|
70
|
+
},
|
71
|
+
easeOutQuart: function (x, t, b, c, d) {
|
72
|
+
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
73
|
+
},
|
74
|
+
easeInOutQuart: function (x, t, b, c, d) {
|
75
|
+
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
76
|
+
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
77
|
+
},
|
78
|
+
easeInQuint: function (x, t, b, c, d) {
|
79
|
+
return c*(t/=d)*t*t*t*t + b;
|
80
|
+
},
|
81
|
+
easeOutQuint: function (x, t, b, c, d) {
|
82
|
+
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
83
|
+
},
|
84
|
+
easeInOutQuint: function (x, t, b, c, d) {
|
85
|
+
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
86
|
+
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
87
|
+
},
|
88
|
+
easeInSine: function (x, t, b, c, d) {
|
89
|
+
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
90
|
+
},
|
91
|
+
easeOutSine: function (x, t, b, c, d) {
|
92
|
+
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
93
|
+
},
|
94
|
+
easeInOutSine: function (x, t, b, c, d) {
|
95
|
+
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
96
|
+
},
|
97
|
+
easeInExpo: function (x, t, b, c, d) {
|
98
|
+
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
99
|
+
},
|
100
|
+
easeOutExpo: function (x, t, b, c, d) {
|
101
|
+
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
102
|
+
},
|
103
|
+
easeInOutExpo: function (x, t, b, c, d) {
|
104
|
+
if (t==0) return b;
|
105
|
+
if (t==d) return b+c;
|
106
|
+
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
107
|
+
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
108
|
+
},
|
109
|
+
easeInCirc: function (x, t, b, c, d) {
|
110
|
+
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
111
|
+
},
|
112
|
+
easeOutCirc: function (x, t, b, c, d) {
|
113
|
+
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
114
|
+
},
|
115
|
+
easeInOutCirc: function (x, t, b, c, d) {
|
116
|
+
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
117
|
+
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
118
|
+
},
|
119
|
+
easeInElastic: function (x, t, b, c, d) {
|
120
|
+
var s=1.70158;var p=0;var a=c;
|
121
|
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
122
|
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
123
|
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
124
|
+
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
125
|
+
},
|
126
|
+
easeOutElastic: function (x, t, b, c, d) {
|
127
|
+
var s=1.70158;var p=0;var a=c;
|
128
|
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
129
|
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
130
|
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
131
|
+
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
132
|
+
},
|
133
|
+
easeInOutElastic: function (x, t, b, c, d) {
|
134
|
+
var s=1.70158;var p=0;var a=c;
|
135
|
+
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
136
|
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
137
|
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
138
|
+
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
139
|
+
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
140
|
+
},
|
141
|
+
easeInBack: function (x, t, b, c, d, s) {
|
142
|
+
if (s == undefined) s = 1.70158;
|
143
|
+
return c*(t/=d)*t*((s+1)*t - s) + b;
|
144
|
+
},
|
145
|
+
easeOutBack: function (x, t, b, c, d, s) {
|
146
|
+
if (s == undefined) s = 1.70158;
|
147
|
+
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
148
|
+
},
|
149
|
+
easeInOutBack: function (x, t, b, c, d, s) {
|
150
|
+
if (s == undefined) s = 1.70158;
|
151
|
+
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
152
|
+
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
153
|
+
},
|
154
|
+
easeInBounce: function (x, t, b, c, d) {
|
155
|
+
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
156
|
+
},
|
157
|
+
easeOutBounce: function (x, t, b, c, d) {
|
158
|
+
if ((t/=d) < (1/2.75)) {
|
159
|
+
return c*(7.5625*t*t) + b;
|
160
|
+
} else if (t < (2/2.75)) {
|
161
|
+
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
162
|
+
} else if (t < (2.5/2.75)) {
|
163
|
+
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
164
|
+
} else {
|
165
|
+
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
166
|
+
}
|
167
|
+
},
|
168
|
+
easeInOutBounce: function (x, t, b, c, d) {
|
169
|
+
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
170
|
+
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
171
|
+
}
|
172
|
+
});
|
173
|
+
|
174
|
+
/*
|
175
|
+
*
|
176
|
+
* TERMS OF USE - EASING EQUATIONS
|
177
|
+
*
|
178
|
+
* Open source under the BSD License.
|
179
|
+
*
|
180
|
+
* Copyright © 2001 Robert Penner
|
181
|
+
* All rights reserved.
|
182
|
+
*
|
183
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
184
|
+
* are permitted provided that the following conditions are met:
|
185
|
+
*
|
186
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
187
|
+
* conditions and the following disclaimer.
|
188
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
189
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
190
|
+
* provided with the distribution.
|
191
|
+
*
|
192
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
193
|
+
* or promote products derived from this software without specific prior written permission.
|
194
|
+
*
|
195
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
196
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
197
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
198
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
199
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
200
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
201
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
202
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
203
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
204
|
+
*
|
205
|
+
*/
|