- jQuery.anime is a plugin that add steroids to the $.fn.animate function of jQuery. You can force or select to do animate with CSS3 or by javascript, and activate the hardware acceleration by adding CSS3 3D properties (not 3D animation by this time).
- Language
- JavaScript
- Tags
- 3d animation css3 jquery transform transitions
jQuery.anime
1 /*
2 * jQuery ANIME
3 * per ID (uid) animation fx by default works like is not queued if queued=false||undefined - microbians.com
4 * version 0.5
5 * Released under the MIT license.
6 * Based partialy on jquery.fxqueues.js
7 * version 0.5 - BUG's on stop corrected
8 * version 0.4 - Added CSS3 transitions for animate in modern browsers
9 * version 0.1 - Added multiple queue for each obj and indivifual opacity per queue
10 * CSS3 Timming table by André Fiedler from script: Fx.Tween.CSS3.js
11 * CSS2 Timming table by ease jquery plugin based on Robert P. equations & based on easing jQuery plugin by George McGinley Smith
12 *
13 * Requieres: jquery.css3.js
14 * Requieres: jquery.is.js
15 *
16 */
17
18 ANIMATIONFRAMESxSECOND=60;
19 ANIMATIONTICK=Math.floor(1000/ANIMATIONFRAMESxSECOND);
20 MAXIMUNOPACITY = .999; // Solve a bug in safari that over print antialiasing
21
22 ;(function($) {
23
24 var transitionTimingsCSS3={
25 'linear' : 'cubic-bezier(0,0,1,1)',
26 'easein' : 'cubic-bezier(0.14,0.01,0.49,0)',
27 'easeout' : 'cubic-bezier(0.01,0,0.43,1)',
28 'easeinout' : 'cubic-bezier(0.47,0.04,0.53,0.96)',
29 'expoin' : 'cubic-bezier(0.71,0.01,0.83,0)',
30 'expoout' : 'cubic-bezier(0.14,1,0.32,0.99)',
31 'expoinout' : 'cubic-bezier(0.85,0,0.15,1)',
32 'circin' : 'cubic-bezier(0.34,0,0.96,0.23)',
33 'circout' : 'cubic-bezier(0,0.5,0.37,0.98)',
34 'circinout' : 'cubic-bezier(0.88,0.1,0.12,0.9)',
35 'sinein' : 'cubic-bezier(0.22,0.04,0.36,0)',
36 'sineout' : 'cubic-bezier(0.04,0,0.5,1)',
37 'sineinout' : 'cubic-bezier(0.37,0.01,0.63,1)',
38 'quadin' : 'cubic-bezier(0.14,0.01,0.49,0)',
39 'quadout' : 'cubic-bezier(0.01,0,0.43,1)',
40 'quadinout' : 'cubic-bezier(0.47,0.04,0.53,0.96)',
41 'cubicin' : 'cubic-bezier(0.35,0,0.65,0)',
42 'cubicout' : 'cubic-bezier(0.09,0.25,0.24,1)',
43 'cubicinout' : 'cubic-bezier(0.66,0,0.34,1)',
44 'quartin' : 'cubic-bezier(0.69,0,0.76,0.17)',
45 'quartout' : 'cubic-bezier(0.26,0.96,0.44,1)',
46 'quartinout' : 'cubic-bezier(0.76,0,0.24,1)',
47 'quintin' : 'cubic-bezier(0.64,0,0.78,0)',
48 'quintout' : 'cubic-bezier(0.22,1,0.35,1)',
49 'quintinout' : 'cubic-bezier(0.9,0,0.1,1)',
50 'applescroll' : 'cubic-bezier(0,0,0.25,1)'
51 };
52
53 var transitionTimingsCSS2={
54 'linear' : function( p, n, firstNum, diff ) {return firstNum + diff * p;},
55 'easein' : function (x, t, b, c, d) { return c*(t/=d)*t + b;},
56 'easeout' : function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b;},
57 'easeinout' : function (x, t, b, c, d) { if ((t/=d/2) < 1) { return c/2*t*t + b;}; return -c/2 * ((--t)*(t-2) - 1) + b;},
58 'expoin' : function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;},
59 'expoout' : function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;},
60 'expoinout' : function (x, t, b, c, d) { if (t==0) {return b;}; if (t==d) {return b+c;}; if ((t/=d/2) < 1) {return c/2 * Math.pow(2, 10 * (t - 1)) + b;}; return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;},
61 'circin' : function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;},
62 'circout' : function (x, t, b, c, d) { return c * Math.sqrt(1 - (t=t/d-1)*t) + b;},
63 'circinout' : function (x, t, b, c, d) { if ((t/=d/2) < 1) {return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;}; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;},
64 'sinein' : function (x, t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b;},
65 'sineout' : function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b;},
66 'sineinout' : function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;},
67 'quadin' : function (x, t, b, c, d) { return c*(t/=d)*t + b;},
68 'quadout' : function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b;},
69 'quadinout' : function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b;},
70 'cubicin' : function (x, t, b, c, d) { return c*(t/=d)*t*t + b;},
71 'cubicout' : function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b;},
72 'cubicinout' : function (x, t, b, c, d) { if ((t/=d/2) < 1) {return c/2*t*t*t + b;}; return c/2*((t-=2)*t*t + 2) + b;},
73 'quartin' : function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b;},
74 'quartout' : function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b;},
75 'quartinout' : function (x, t, b, c, d) { if ((t/=d/2) < 1) {return c/2*t*t*t*t + b;}; return -c/2 * ((t-=2)*t*t*t - 2) + b;},
76 'quintin' : function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b;},
77 'quintout' : function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b;},
78 'quintinout' : function (x, t, b, c, d) { if ((t/=d/2) < 1) { return c/2*t*t*t*t*t + b;}; return c/2*((t-=2)*t*t*t*t + 2) + b;}
79 };
80
81 // Backup core jQuery functions
82 var $animate = $.fn.animate;
83 var $fadeIn = $.fn.fadeIn;
84 var $fadeOut = $.fn.fadeOut;
85 var $fadeTo = $.fn.fadeTo;
86 var $show = $.fn.show;
87 var $hide = $.fn.hide;
88 var $delay = $.fn.delay;
89 var $stop = $.fn.stop;
90
91 // Unique ID generator
92 var UID=0;
93 $.fn.UID = function(){
94 var obj=$(this);
95 if (obj.data('UID')==undefined) {
96 obj.data('UID', UID);
97 UID++;
98 }
99 return obj.data('UID');
100 }
101
102 now=function(){
103 return (new Date).getTime();
104 }
105
106 getUIDQueueName = function(obj, q){
107 return 'F_'+obj.UID()+'_'+q+'';
108 }
109
110 $.fn.animationQueue = function(queueName, renew){
111 var obj=$(this);
112 var q=getUIDQueueName(obj, queueName);
113
114 if ( (renew!==undefined||renew===true) && obj.data(q)!=undefined ){
115 obj.data(q).status='stop';
116 obj.data(q).isAnimQueue='false';
117 obj.removeData(q);
118 }
119
120 if (obj.data(q)==undefined) {
121 obj.data(q, new Array());
122 obj.data(q).status='start';
123 obj.data(q).isAnimQueue=true;
124 }
125 return obj.data(q);
126 }
127
128 $.fn.addAnimationToQueue=function(queueName, anim){
129 var obj=$(this);
130 var animQueue=obj.animationQueue(queueName); // Init the queue and/or return it
131 animQueue.push(anim);
132 return animQueue;
133 }
134
135 $.fn.animate = function(prop, opt) {
136 if ( typeof(opt)!='object' ) {
137 return $animate.apply( this, arguments );
138 }
139 return $(this).each(function(){
140 var obj=$(this);
141 var stop=opt.stop;
142 var queueName=opt.queue;
143 var animQueue=obj.animationQueue(queueName);
144
145 if (animQueue==null) return;
146 if (animQueue.length===0) stop=false;
147
148 if (queueName==false) { stop=true; queueName=''; }
149 if (queueName==true) { stop=false; queueName=''; }
150
151 if (stop==undefined) stop=false;
152
153 if (stop===true && animQueue.length>0) obj.stop(queueName);
154
155 // IF the queue is stoped then start it because we start on each animate call
156 // IF the queue is in pause will not start until user set to play with .play
157 if (animQueue.status=='stop') {
158 // Clean preview queue because it become from a stop
159 var animQueue=obj.animationQueue(queueName,true);
160 animQueue.status='start';
161 }
162
163 var duration=opt.duration;
164 if (opt.duration=='fast') var duration=200;
165 else if (opt.duration=='slow') var duration=600;
166 else if (opt.duration==undefined) var duration=400;
167 else if (typeof(opt.duration)=='string') var duration=400;
168
169 var type=opt.type;
170
171 if (type===undefined && (isiPad||isiPhone||isiPod)) type='TRANSITION';
172
173 if (CSS3TransitionProperty===undefined) type='JS';
174
175 if (type===undefined||type.toUpperCase()==='JS') {
176 if (opt.easing==undefined) var easing=transitionTimingsCSS2['linear'];
177 else var easing=transitionTimingsCSS2[opt.easing.toLowerCase()];
178 } else {
179 if (opt.easing==undefined) var easing=transitionTimingsCSS3['linear'];
180 else var easing=transitionTimingsCSS3[opt.easing.toLowerCase()];
181 }
182
183 var animQueue=obj.addAnimationToQueue(queueName, {prop:prop, opt:{type:type, queue: queueName, duration:duration, easing:easing, step:opt.step, complete:opt.complete} });
184
185 if (animQueue.status==='start') obj.play(queueName);
186
187 });
188 }
189
190 $.fn.startAnimation_JS = function(queueName){
191 var obj=$(this);
192 var animQueue=obj.animationQueue(queueName);
193
194 // Queue was destroy somewhere so return.
195 if (animQueue!=undefined && animQueue!='') {
196
197 var curAnim=animQueue[0];
198
199 var prop=curAnim.prop;
200 var opt=curAnim.opt;
201
202 curAnim.startTime=now();
203 curAnim.start=true
204 curAnim.initialProp=new Object();
205
206 var that=curAnim.initialProp;
207
208 var is3DTransform=($(this).css('backface-visibility')!=='visible'||$(this).css('perspective')!=='none'||$(this).css('transform').indexOf('Z')!=-1||$(this).css('transform').indexOf('3d')!=-1);
209
210 if (!is3DTransform) {
211 for (var p in curAnim.prop) {
212 if (p==='translate'||p==='scale'||p==='rotate') {
213 is3DTransform=true;
214 break;
215 }
216 }
217 }
218
219 if (!is3DTransform) {
220 // Hack to get hardware acceleration part1
221 var property3D ='transform';
222 var hardwareAcceletarion3D=obj.css(property3D);
223 if (hardwareAcceletarion3D==undefined||'none') var value3D='scale3d(1,1,1)';
224 else var value3D=hardwareAcceletarion3D;
225
226 obj.css(property3D, value3D);
227 }
228
229 curAnim.timer=setInterval(function(){
230 // This "if" is necesary because queue anim can be destroy somewhere in the middle...
231 if (curAnim!=undefined) {
232 var t=now();
233 var n=t-curAnim.startTime;
234 var c=n/curAnim.opt.duration;
235 }
236
237 if (animQueue!=undefined && animQueue!='' && animQueue.status=='play') {
238 var value=curAnim.opt.easing(c, n, 0, 1, curAnim.opt.duration);
239
240 if (t < curAnim.startTime+curAnim.opt.duration ) {
241 // The first captures the current state of the properties
242 if (curAnim.start==true) {
243 curAnim.start=false;
244 for (var p in curAnim.prop) {
245 switch(p) {
246 case 'opacity':
247 that[p]=obj.opacity(undefined, queueName); // Set a opacity for this queue (if the opacty name for this queue not exist it will be created)
248 break;
249 case 'translate':
250 that[p]=obj.translate(); // Copy start values for p
251 break;
252 case 'scale':
253 that[p]=obj.scale(); // Copy start values for p
254 break;
255 case 'rotate':
256 that[p]=obj.rotate(); // Copy start values for p
257 break;
258 default:
259 that[p]=parseFloat(obj.css(p));
260 if (that[p]+''=='NaN') {
261 that[p]=0;
262 }
263 }
264 }
265 }
266
267 // Then whe make the prop changes
268 for (var p in curAnim.prop) {
269 // This "if" is because a bug on iPad
270 if (that[p]!==undefined) {
271 switch(p) {
272 case 'opacity':
273 obj.opacity(value*parseFloat(curAnim.prop[p])+(1-value)*that[p], queueName); // Set a opacity for this queue (if the opacty name for this queue not exist it will be created)
274 break;
275 case 'translate':
276 var val=curAnim.prop[p];
277 var x=val.x!=undefined?value*parseFloat(val.x)+(1-value)*that[p].x:undefined;
278 var y=val.y!=undefined?value*parseFloat(val.y)+(1-value)*that[p].y:undefined;
279 var z=val.z!=undefined?value*parseFloat(val.z)+(1-value)*that[p].z:undefined;
280 obj.translate(x,y,z);
281 break;
282 case 'scale':
283 var val=curAnim.prop[p];
284 var x=val.x!=undefined?value*parseFloat(val.x)+(1-value)*that[p].x:undefined;
285 var y=val.y!=undefined?value*parseFloat(val.y)+(1-value)*that[p].y:undefined;
286 var z=val.z!=undefined?value*parseFloat(val.z)+(1-value)*that[p].z:undefined;
287 obj.scale(x,y,z);
288 break;
289 case 'rotate':
290 var val=curAnim.prop[p];
291 var x=val.x!=undefined?value*parseFloat(val.x)+(1-value)*that[p].x:undefined;
292 var y=val.y!=undefined?value*parseFloat(val.y)+(1-value)*that[p].y:undefined;
293 var z=val.z!=undefined?value*parseFloat(val.z)+(1-value)*that[p].z:undefined;
294 obj.rotate(x,y,z);
295 break;
296 default:
297 obj.css( p, value*parseFloat(curAnim.prop[p])+(1-value)*that[p] );
298 }
299 }
300
301 }
302 if ( $.isFunction(curAnim.opt.step) ) curAnim.opt.step.call(obj);
303
304 } else {
305
306 // We need to finish... complete
307 clearInterval(curAnim.timer); // Stop timer
308
309 // Is las time we put the last value
310 for (var p in curAnim.prop) {
311 switch(p) {
312 case 'opacity':
313 obj.opacity(parseFloat(curAnim.prop[p]), queueName); // Set a opacity for this queue (if the opacty name for this queue not exist it will be created)
314 break;
315 case 'translate':
316 var values=curAnim.prop[p];
317 var x=values.x!=undefined?parseFloat(values.x):undefined;
318 var y=values.y!=undefined?parseFloat(values.y):undefined;
319 var z=values.z!=undefined?parseFloat(values.z):undefined;
320 obj.translate(x,y,z);
321 break;
322 case 'scale':
323 var values=curAnim.prop[p];
324 var x=values.x!=undefined?parseFloat(values.x):undefined;
325 var y=values.y!=undefined?parseFloat(values.y):undefined;
326 var z=values.z!=undefined?parseFloat(values.z):undefined;
327 obj.scale(x,y,z);
328 break;
329 case 'rotate':
330 var values=curAnim.prop[p];
331 var x=values.x!=undefined?parseFloat(values.x):undefined;
332 var y=values.y!=undefined?parseFloat(values.y):undefined;
333 var z=values.z!=undefined?parseFloat(values.z):undefined;
334 obj.rotate(x,y,z);
335 break;
336 default:
337 obj.css( p, parseFloat(curAnim.prop[p]) );
338 }
339 }
340
341 if (!is3DTransform) {
342 // Hack to get hardware acceleration part2
343 obj.css(property3D, hardwareAcceletarion3D);
344 }
345
346 animQueue.splice(0, 1);
347
348 if (animQueue.length>0) {
349 setTimeout(function(){
350 obj.startAnimation(queueName);
351 },1);
352 } else {
353 animQueue.status='stop';
354 animQueue.length=0;
355 }
356
357 if ( $.isFunction(curAnim.opt.complete) ) curAnim.opt.complete.call(obj);
358 }
359 }
360 }, ANIMATIONTICK);
361 } else return;
362 }
363
364 $.fn.startAnimation_CSS3Transition = function(queueName){
365
366 var obj=$(this);
367 var animQueue=obj.animationQueue(queueName);
368 var q=getUIDQueueName(obj, queueName);
369
370 // Queue was destroy somewhere so return.
371 if (animQueue!=undefined && animQueue!='') {
372 var curAnim=animQueue[0];
373
374 if (obj.data("transitions")==undefined){
375 obj.data("transitions", new Array());
376 }
377
378 var is3DTransform=($(this).css('backface-visibility')!=='visible'||$(this).css('perspective')!=='none'||$(this).css('transform').indexOf('Z')!=-1||$(this).css('transform').indexOf('3d')!=-1);
379
380 for (var p in curAnim.prop) {
381 if (p==='translate'||p==='scale'||p==='rotate') {
382 p=getCSS3Name['transform'];
383 is3DTransform=true;
384 }
385 obj.data("transitions").push(p +' '+curAnim.opt.duration+'ms '+curAnim.opt.easing);
386 }
387
388 if (!is3DTransform) {
389 // Hack to get hardware acceleration part1
390 var property3D ='backface-visibility';
391 var hardwareAcceletarion3D=obj.css(property3D);
392 if (hardwareAcceletarion3D==undefined||'none') var value3D='hidden';
393 else var value3D=hardwareAcceletarion3D;
394
395 obj.css(property3D, value3D);
396 }
397
398 // Hack to refresh page (because a bug??)
399 if ($('#animeFakeDiv').length>0) {
400 $('#animeFakeDiv').html();
401 } else {
402 $('body').append( '<div id="animeFakeDiv" style="display:none"></div>' );
403 }
404
405 // Generate transition - Executed & refresh browser
406 obj.css('transition', obj.data("transitions").join(','));
407
408 // Refresh animation
409 for (var p in curAnim.prop) {
410 switch(p) {
411 case 'opacity':
412 obj.opacity( parseFloat(curAnim.prop[p]), queueName, false); // Set a opacity for this queue (if the opacty name for this queue not exist it will be created)
413 break;
414 case 'translate':
415 var values=curAnim.prop[p];
416 var x=values.x!=undefined?parseFloat(values.x):undefined;
417 var y=values.y!=undefined?parseFloat(values.y):undefined;
418 var z=values.z!=undefined?parseFloat(values.z):undefined;
419 obj.translate(x,y,z);
420 break;
421 case 'scale':
422 var values=curAnim.prop[p];
423 var x=values.x!=undefined?parseFloat(values.x):undefined;
424 var y=values.y!=undefined?parseFloat(values.y):undefined;
425 var z=values.z!=undefined?parseFloat(values.z):undefined;
426 obj.scale(x,y,z);
427 break;
428 case 'rotate':
429 var values=curAnim.prop[p];
430 var x=values.x!=undefined?parseFloat(values.x):undefined;
431 var y=values.y!=undefined?parseFloat(values.y):undefined;
432 var z=values.z!=undefined?parseFloat(values.z):undefined;
433 obj.rotate(x,y,z);
434 break;
435 default:
436 obj.css(p, parseFloat(curAnim.prop[p]));
437 }
438 }
439
440 curAnim.timerFinish=false;
441 curAnim.transitionFinish=false;
442
443 curAnim.timerEnd=function(){
444 curAnim.finish=true;
445 if (curAnim.timeStart+curAnim.opt.duration+100>(new Date()).getTime() && curAnim.transitionFinish==false) {
446 setTimeout(curAnim.timerEnd,1);
447 return;
448 }
449 obj.unbind( CSS3TransitionEvent );
450 animQueue.splice(0, 1);
451
452 // Clear transitions in use
453 for (var p in curAnim.prop) {
454 if (p==='translate'||p==='scale'||p==='rotate') {
455 p=getCSS3Name['transform'];
456 }
457
458 if (obj.data("transitions")!=undefined) {
459 for (var i=0; i<obj.data("transitions").length; i++){
460 if (obj.data("transitions")[i].indexOf(p)!=-1) {
461 obj.data("transitions").splice(i,1);
462 }
463 }
464 }
465 }
466 // Reset transition as we take out some properties
467 if (obj.data("transitions")!=undefined) {
468 obj.css('transition', obj.data("transitions").join(','));
469 }
470
471 if (animQueue.length>0) {
472 // Set visibility - Executed & refresh browser
473 setTimeout(function(){
474 // First check if is needed to change visibility before start the animation
475 // This is needed because a bug do not set visibility until the end of the transition
476 var curAnim=animQueue[0];
477
478 if (curAnim!==undefined) {
479 if (curAnim.prop['opacity']!==undefined) {
480 var new_opacity=obj.opacityGetRealValues()+parseFloat(curAnim.prop['opacity']);
481 if (new_opacity>0) obj.css('visibility','visible');
482 else obj.css('visibility','hidden');
483 }
484 }
485
486 if (!is3DTransform) {
487 // Hack to get hardware acceleration part2
488 obj.css(property3D, hardwareAcceletarion3D);
489 }
490
491 // Next queue - Executed & refresh browser
492 setTimeout(function(){
493 obj.startAnimation(queueName);
494 },1);
495 },1);
496 } else {
497 animQueue.status='stop';
498 animQueue.length=0;
499 }
500 if ( $.isFunction(curAnim.opt.complete) ) curAnim.opt.complete.call(obj);
501 };
502
503 curAnim.timeStart=(new Date()).getTime();
504 obj.bind( CSS3TransitionEvent, function(){
505 curAnim.transitionFinish=true;
506 if (curAnim.finish==false) {
507 clearTimeout(curAnim.timer);
508 obj.unbind( CSS3TransitionEvent );
509 setTimeout(curAnim.timerEnd,1);
510 }
511 });
512 curAnim.timer=setTimeout(curAnim.timerEnd, curAnim.opt.duration);
513
514 }
515 }
516
517 $.fn.startAnimation=function(queueName){
518 var obj=$(this);
519 var animQueue=obj.animationQueue(queueName);
520 // Queue was destroy somewhere so return.
521 if (animQueue!=undefined && animQueue!='') {
522 var curAnim=animQueue[0];
523
524 if (curAnim.opt.type===undefined||curAnim.opt.type.toUpperCase()==='JS') {
525 obj.startAnimation_JS(queueName);
526 } else {
527
528 // Check there is a 3D prop to anim and check if the object wasn't 3d before and activates as 3D
529 // because ipad if not start the scale as 0,0,0
530 var is3DTransform=($(this).css('backface-visibility')!=='visible'||$(this).css('perspective')!=='none'||$(this).css('transform').indexOf('Z')!=-1||$(this).css('transform').indexOf('3d')!=-1);
531
532 for (var p in curAnim.prop) {
533 if (p==='translate'||p==='scale'||p==='rotate') {
534 // init the object for transition 3D
535 if (!is3DTransform) obj.scale(1,1,1);
536 break;
537 }
538 }
539
540 obj.startAnimation_CSS3Transition(queueName);
541 }
542 }
543 }
544
545 $.fn.stop=function(queueName){
546 if ( typeof(queueName)!='string' ) {
547 return $stop.apply( this, arguments );
548 }
549
550 return $(this).each(function(){
551 var obj=$(this);
552 var q=getUIDQueueName(obj, queueName);
553
554 var animQueue=obj.animationQueue(queueName); // Init the queue and/or return it
555
556 for (var i=animQueue.length-1; i>=0; i--) {
557 var curAnim=animQueue[i];
558 if (curAnim!=undefined && curAnim.timer) clearTimeout(curAnim.timer);
559 animQueue.splice(i,1);
560 }
561 animQueue.length=0;
562
563 if (CSS3TransitionProperty!==undefined) {
564 obj.css('transition','');
565 obj.css('transition-duration','');
566 obj.unbind(CSS3TransitionEvent);
567 }
568
569 animQueue.status='stop';
570 });
571 }
572
573 $.fn.play=function(queueName){
574 return $(this).each(function(){
575 var obj=$(this);
576 var animQueue=obj.animationQueue(queueName); // Init the queue and/or return it
577
578 if (animQueue.status==='start'||animQueue.status==='pause') {
579 animQueue.status='play';
580 obj.startAnimation(queueName);
581 } else {
582 if (animQueue.status!=='play') {
583 animQueue.status='play';
584 obj.startAnimation(queueName);
585 }
586 }
587 });
588 }
589
590 $.fn.pause=function(queueName){
591 return $(this).each(function(){
592 var obj=$(this);
593 var animQueue=obj.animationQueue(queueName); // Init the queue and/or return it
594 var curAnim=animQueue[0];
595 if (curAnim!=undefined && curAnim.timer) {
596 clearTimeout(curAnim.timer);
597 }
598
599 if (CSS3TransitionProperty!==undefined) {
600 obj.unbind(CSS3TransitionEvent);
601 }
602
603 animQueue.status='pause';
604 });
605 }
606
607 $.fn.fadeTo=function(opt, o, c){
608 if ( typeof(opt)!='object') return $fadeTo.apply( this, arguments );
609 return $(this).animate({opacity: opt.value}, opt);
610 }
611
612 $.fn.fadeIn=function(opt, c){
613 if ( typeof(opt)!='object') return $fadeIn.apply( this, arguments );
614 return $(this).animate({opacity:1}, opt);
615 }
616
617 $.fn.fadeOut=function(opt, c){
618 if ( typeof(opt)!='object') return $fadeOut.apply( this, arguments );
619 return $(this).animate({opacity:0}, opt);
620 }
621
622 $.fn.show=function(opt, c){
623 if ( typeof(opt)!='object') return $show.apply( this, arguments );
624
625 var value = ((opt.value===undefined)?1:opt.value);
626 var duration = ((opt.duration===undefined)?0:opt.duration);
627
628 if (duration===0) {
629 $(this).animate({opacity:value}, {type:opt.type, stop:opt.stop, global:opt.global, queue:opt.queue, duration:0 , step:opt.step, easing:opt.easing, complete:opt.complete });
630 } else {
631 $(this).animate({opacity:value}, {type:opt.type, stop:opt.stop, global:opt.global, queue:opt.queue, duration:0 , step:opt.step, easing:opt.easing });
632 $(this).animate({opacity:value}, {type:opt.type, stop:false , global:opt.global, queue:opt.queue, duration:duration , step:opt.step, easing:opt.easing, complete:opt.complete });
633 }
634 return $(this);
635 }
636
637 $.fn.hide=function(opt, c){
638 if ( typeof(opt)!='object') return $hide.apply( this, arguments );
639 return $(this).show({value:0, type:opt.type, stop:opt.stop, global:opt.global, queue:opt.queue, duration:opt.duration, step:opt.step, easing:opt.easing, complete:opt.complete });
640 }
641
642 $.fn.delay=function(opt, arg2) {
643 if ( typeof(opt)!='object') return $delay.apply( this, arguments );
644 // Delay is a void fake animation
645 return $(this).animate({}, opt);
646 }
647
648 })(jQuery);
Comments
Sign in to leave a comment.

