[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /*! 2 * jQuery UI Effects Bounce 1.13.1 3 * http://jqueryui.com 4 * 5 * Copyright jQuery Foundation and other contributors 6 * Released under the MIT license. 7 * http://jquery.org/license 8 */ 9 10 //>>label: Bounce Effect 11 //>>group: Effects 12 //>>description: Bounces an element horizontally or vertically n times. 13 //>>docs: http://api.jqueryui.com/bounce-effect/ 14 //>>demos: http://jqueryui.com/effect/ 15 16 ( function( factory ) { 17 "use strict"; 18 19 if ( typeof define === "function" && define.amd ) { 20 21 // AMD. Register as an anonymous module. 22 define( [ 23 "jquery", 24 "./effect" 25 ], factory ); 26 } else { 27 28 // Browser globals 29 factory( jQuery ); 30 } 31 } )( function( $ ) { 32 "use strict"; 33 34 return $.effects.define( "bounce", function( options, done ) { 35 var upAnim, downAnim, refValue, 36 element = $( this ), 37 38 // Defaults: 39 mode = options.mode, 40 hide = mode === "hide", 41 show = mode === "show", 42 direction = options.direction || "up", 43 distance = options.distance, 44 times = options.times || 5, 45 46 // Number of internal animations 47 anims = times * 2 + ( show || hide ? 1 : 0 ), 48 speed = options.duration / anims, 49 easing = options.easing, 50 51 // Utility: 52 ref = ( direction === "up" || direction === "down" ) ? "top" : "left", 53 motion = ( direction === "up" || direction === "left" ), 54 i = 0, 55 56 queuelen = element.queue().length; 57 58 $.effects.createPlaceholder( element ); 59 60 refValue = element.css( ref ); 61 62 // Default distance for the BIGGEST bounce is the outer Distance / 3 63 if ( !distance ) { 64 distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; 65 } 66 67 if ( show ) { 68 downAnim = { opacity: 1 }; 69 downAnim[ ref ] = refValue; 70 71 // If we are showing, force opacity 0 and set the initial position 72 // then do the "first" animation 73 element 74 .css( "opacity", 0 ) 75 .css( ref, motion ? -distance * 2 : distance * 2 ) 76 .animate( downAnim, speed, easing ); 77 } 78 79 // Start at the smallest distance if we are hiding 80 if ( hide ) { 81 distance = distance / Math.pow( 2, times - 1 ); 82 } 83 84 downAnim = {}; 85 downAnim[ ref ] = refValue; 86 87 // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here 88 for ( ; i < times; i++ ) { 89 upAnim = {}; 90 upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; 91 92 element 93 .animate( upAnim, speed, easing ) 94 .animate( downAnim, speed, easing ); 95 96 distance = hide ? distance * 2 : distance / 2; 97 } 98 99 // Last Bounce when Hiding 100 if ( hide ) { 101 upAnim = { opacity: 0 }; 102 upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; 103 104 element.animate( upAnim, speed, easing ); 105 } 106 107 element.queue( done ); 108 109 $.effects.unshift( element, queuelen, anims + 1 ); 110 } ); 111 112 } );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |