@@ -564,210 +564,49 @@ $.fn.extend({
564
564
/*********************************** EASING ***********************************/
565
565
/******************************************************************************/
566
566
567
- /*
568
- * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
569
- *
570
- * Uses the built in easing capabilities added In jQuery 1.1
571
- * to offer multiple easing options
572
- *
573
- * TERMS OF USE - jQuery Easing
574
- *
575
- * Open source under the BSD License.
576
- *
577
- * Copyright 2008 George McGinley Smith
578
- * All rights reserved.
579
- *
580
- * Redistribution and use in source and binary forms, with or without modification,
581
- * are permitted provided that the following conditions are met:
582
- *
583
- * Redistributions of source code must retain the above copyright notice, this list of
584
- * conditions and the following disclaimer.
585
- * Redistributions in binary form must reproduce the above copyright notice, this list
586
- * of conditions and the following disclaimer in the documentation and/or other materials
587
- * provided with the distribution.
588
- *
589
- * Neither the name of the author nor the names of contributors may be used to endorse
590
- * or promote products derived from this software without specific prior written permission.
591
- *
592
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
593
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
594
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
595
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
596
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
597
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
598
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
599
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
600
- * OF THE POSSIBILITY OF SUCH DAMAGE.
601
- *
602
- */
567
+ // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
603
568
604
- // t: current time, b: begInnIng value, c: change In value, d: duration
605
- $ . easing . jswing = $ . easing . swing ;
569
+ var baseEasings = { } ;
606
570
607
- $ . extend ( $ . easing ,
608
- {
609
- def : 'easeOutQuad' ,
610
- swing : function ( x , t , b , c , d ) {
611
- //alert($.easing.default);
612
- return $ . easing [ $ . easing . def ] ( x , t , b , c , d ) ;
613
- } ,
614
- easeInQuad : function ( x , t , b , c , d ) {
615
- return c * ( t /= d ) * t + b ;
616
- } ,
617
- easeOutQuad : function ( x , t , b , c , d ) {
618
- return - c * ( t /= d ) * ( t - 2 ) + b ;
619
- } ,
620
- easeInOutQuad : function ( x , t , b , c , d ) {
621
- if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t + b ;
622
- return - c / 2 * ( ( -- t ) * ( t - 2 ) - 1 ) + b ;
623
- } ,
624
- easeInCubic : function ( x , t , b , c , d ) {
625
- return c * ( t /= d ) * t * t + b ;
626
- } ,
627
- easeOutCubic : function ( x , t , b , c , d ) {
628
- return c * ( ( t = t / d - 1 ) * t * t + 1 ) + b ;
629
- } ,
630
- easeInOutCubic : function ( x , t , b , c , d ) {
631
- if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t + b ;
632
- return c / 2 * ( ( t -= 2 ) * t * t + 2 ) + b ;
633
- } ,
634
- easeInQuart : function ( x , t , b , c , d ) {
635
- return c * ( t /= d ) * t * t * t + b ;
636
- } ,
637
- easeOutQuart : function ( x , t , b , c , d ) {
638
- return - c * ( ( t = t / d - 1 ) * t * t * t - 1 ) + b ;
639
- } ,
640
- easeInOutQuart : function ( x , t , b , c , d ) {
641
- if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t + b ;
642
- return - c / 2 * ( ( t -= 2 ) * t * t * t - 2 ) + b ;
643
- } ,
644
- easeInQuint : function ( x , t , b , c , d ) {
645
- return c * ( t /= d ) * t * t * t * t + b ;
646
- } ,
647
- easeOutQuint : function ( x , t , b , c , d ) {
648
- return c * ( ( t = t / d - 1 ) * t * t * t * t + 1 ) + b ;
649
- } ,
650
- easeInOutQuint : function ( x , t , b , c , d ) {
651
- if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t * t + b ;
652
- return c / 2 * ( ( t -= 2 ) * t * t * t * t + 2 ) + b ;
653
- } ,
654
- easeInSine : function ( x , t , b , c , d ) {
655
- return - c * Math . cos ( t / d * ( Math . PI / 2 ) ) + c + b ;
656
- } ,
657
- easeOutSine : function ( x , t , b , c , d ) {
658
- return c * Math . sin ( t / d * ( Math . PI / 2 ) ) + b ;
659
- } ,
660
- easeInOutSine : function ( x , t , b , c , d ) {
661
- return - c / 2 * ( Math . cos ( Math . PI * t / d ) - 1 ) + b ;
662
- } ,
663
- easeInExpo : function ( x , t , b , c , d ) {
664
- return ( t == 0 ) ? b : c * Math . pow ( 2 , 10 * ( t / d - 1 ) ) + b ;
665
- } ,
666
- easeOutExpo : function ( x , t , b , c , d ) {
667
- return ( t == d ) ? b + c : c * ( - Math . pow ( 2 , - 10 * t / d ) + 1 ) + b ;
668
- } ,
669
- easeInOutExpo : function ( x , t , b , c , d ) {
670
- if ( t == 0 ) return b ;
671
- if ( t == d ) return b + c ;
672
- if ( ( t /= d / 2 ) < 1 ) return c / 2 * Math . pow ( 2 , 10 * ( t - 1 ) ) + b ;
673
- return c / 2 * ( - Math . pow ( 2 , - 10 * -- t ) + 2 ) + b ;
674
- } ,
675
- easeInCirc : function ( x , t , b , c , d ) {
676
- return - c * ( Math . sqrt ( 1 - ( t /= d ) * t ) - 1 ) + b ;
677
- } ,
678
- easeOutCirc : function ( x , t , b , c , d ) {
679
- return c * Math . sqrt ( 1 - ( t = t / d - 1 ) * t ) + b ;
680
- } ,
681
- easeInOutCirc : function ( x , t , b , c , d ) {
682
- if ( ( t /= d / 2 ) < 1 ) return - c / 2 * ( Math . sqrt ( 1 - t * t ) - 1 ) + b ;
683
- return c / 2 * ( Math . sqrt ( 1 - ( t -= 2 ) * t ) + 1 ) + b ;
684
- } ,
685
- easeInElastic : function ( x , t , b , c , d ) {
686
- var s = 1.70158 ; var p = 0 ; var a = c ;
687
- if ( t == 0 ) return b ; if ( ( t /= d ) == 1 ) return b + c ; if ( ! p ) p = d * .3 ;
688
- if ( a < Math . abs ( c ) ) { a = c ; var s = p / 4 ; }
689
- else var s = p / ( 2 * Math . PI ) * Math . asin ( c / a ) ;
690
- return - ( a * Math . pow ( 2 , 10 * ( t -= 1 ) ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) ) + b ;
691
- } ,
692
- easeOutElastic : function ( x , t , b , c , d ) {
693
- var s = 1.70158 ; var p = 0 ; var a = c ;
694
- if ( t == 0 ) return b ; if ( ( t /= d ) == 1 ) return b + c ; if ( ! p ) p = d * .3 ;
695
- if ( a < Math . abs ( c ) ) { a = c ; var s = p / 4 ; }
696
- else var s = p / ( 2 * Math . PI ) * Math . asin ( c / a ) ;
697
- return a * Math . pow ( 2 , - 10 * t ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) + c + b ;
698
- } ,
699
- easeInOutElastic : function ( x , t , b , c , d ) {
700
- var s = 1.70158 ; var p = 0 ; var a = c ;
701
- if ( t == 0 ) return b ; if ( ( t /= d / 2 ) == 2 ) return b + c ; if ( ! p ) p = d * ( .3 * 1.5 ) ;
702
- if ( a < Math . abs ( c ) ) { a = c ; var s = p / 4 ; }
703
- else var s = p / ( 2 * Math . PI ) * Math . asin ( c / a ) ;
704
- if ( t < 1 ) return - .5 * ( a * Math . pow ( 2 , 10 * ( t -= 1 ) ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) ) + b ;
705
- return a * Math . pow ( 2 , - 10 * ( t -= 1 ) ) * Math . sin ( ( t * d - s ) * ( 2 * Math . PI ) / p ) * .5 + c + b ;
706
- } ,
707
- easeInBack : function ( x , t , b , c , d , s ) {
708
- if ( s == undefined ) s = 1.70158 ;
709
- return c * ( t /= d ) * t * ( ( s + 1 ) * t - s ) + b ;
710
- } ,
711
- easeOutBack : function ( x , t , b , c , d , s ) {
712
- if ( s == undefined ) s = 1.70158 ;
713
- return c * ( ( t = t / d - 1 ) * t * ( ( s + 1 ) * t + s ) + 1 ) + b ;
571
+ $ . each ( [ "Quad" , "Cubic" , "Quart" , "Quint" , "Expo" ] , function ( i , name ) {
572
+ baseEasings [ name ] = function ( p ) {
573
+ return Math . pow ( p , i + 2 ) ;
574
+ } ;
575
+ } ) ;
576
+
577
+ $ . extend ( baseEasings , {
578
+ Sine : function ( p ) {
579
+ return 1 - Math . cos ( p * Math . PI / 2 ) ;
714
580
} ,
715
- easeInOutBack : function ( x , t , b , c , d , s ) {
716
- if ( s == undefined ) s = 1.70158 ;
717
- if ( ( t /= d / 2 ) < 1 ) return c / 2 * ( t * t * ( ( ( s *= ( 1.525 ) ) + 1 ) * t - s ) ) + b ;
718
- return c / 2 * ( ( t -= 2 ) * t * ( ( ( s *= ( 1.525 ) ) + 1 ) * t + s ) + 2 ) + b ;
581
+ Circ : function ( p ) {
582
+ return 1 - Math . sqrt ( 1 - p * p ) ;
719
583
} ,
720
- easeInBounce : function ( x , t , b , c , d ) {
721
- return c - $ . easing . easeOutBounce ( x , d - t , 0 , c , d ) + b ;
584
+ Elastic : function ( p ) {
585
+ return p === 0 || p === 1 ? p :
586
+ - Math . pow ( 2 , 8 * ( p - 1 ) ) * Math . sin ( ( ( p - 1 ) * 80 - 7.5 ) * Math . PI / 15 ) ;
722
587
} ,
723
- easeOutBounce : function ( x , t , b , c , d ) {
724
- if ( ( t /= d ) < ( 1 / 2.75 ) ) {
725
- return c * ( 7.5625 * t * t ) + b ;
726
- } else if ( t < ( 2 / 2.75 ) ) {
727
- return c * ( 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + .75 ) + b ;
728
- } else if ( t < ( 2.5 / 2.75 ) ) {
729
- return c * ( 7.5625 * ( t -= ( 2.25 / 2.75 ) ) * t + .9375 ) + b ;
730
- } else {
731
- return c * ( 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + .984375 ) + b ;
732
- }
588
+ Back : function ( p ) {
589
+ return p * p * ( 3 * p - 2 ) ;
733
590
} ,
734
- easeInOutBounce : function ( x , t , b , c , d ) {
735
- if ( t < d / 2 ) return $ . easing . easeInBounce ( x , t * 2 , 0 , c , d ) * .5 + b ;
736
- return $ . easing . easeOutBounce ( x , t * 2 - d , 0 , c , d ) * .5 + c * .5 + b ;
591
+ Bounce : function ( p ) {
592
+ var pow2 ,
593
+ bounce = 4 ;
594
+
595
+ while ( p < ( ( pow2 = Math . pow ( 2 , -- bounce ) ) - 1 ) / 11 ) { }
596
+ return 1 / Math . pow ( 4 , 3 - bounce ) - 7.5625 * Math . pow ( ( pow2 * 3 - 2 ) / 22 - p , 2 ) ;
737
597
}
738
598
} ) ;
739
599
740
- /*
741
- *
742
- * TERMS OF USE - EASING EQUATIONS
743
- *
744
- * Open source under the BSD License.
745
- *
746
- * Copyright 2001 Robert Penner
747
- * All rights reserved.
748
- *
749
- * Redistribution and use in source and binary forms, with or without modification,
750
- * are permitted provided that the following conditions are met:
751
- *
752
- * Redistributions of source code must retain the above copyright notice, this list of
753
- * conditions and the following disclaimer.
754
- * Redistributions in binary form must reproduce the above copyright notice, this list
755
- * of conditions and the following disclaimer in the documentation and/or other materials
756
- * provided with the distribution.
757
- *
758
- * Neither the name of the author nor the names of contributors may be used to endorse
759
- * or promote products derived from this software without specific prior written permission.
760
- *
761
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
762
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
763
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
764
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
765
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
766
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
767
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
768
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
769
- * OF THE POSSIBILITY OF SUCH DAMAGE.
770
- *
771
- */
600
+ $ . each ( baseEasings , function ( name , easeIn ) {
601
+ $ . easing [ "easeIn" + name ] = easeIn ;
602
+ $ . easing [ "easeOut" + name ] = function ( p ) {
603
+ return 1 - easeIn ( 1 - p ) ;
604
+ } ;
605
+ $ . easing [ "easeInOut" + name ] = function ( p ) {
606
+ return p < .5 ?
607
+ easeIn ( p * 2 ) / 2 :
608
+ easeIn ( p * - 2 + 2 ) / - 2 + 1 ;
609
+ } ;
610
+ } ) ;
772
611
773
612
} ) ( jQuery ) ;
0 commit comments