[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /*! 2 * jQuery UI Effects 1.13.3 3 * https://jqueryui.com 4 * 5 * Copyright OpenJS Foundation and other contributors 6 * Released under the MIT license. 7 * https://jquery.org/license 8 */ 9 10 //>>label: Effects Core 11 //>>group: Effects 12 /* eslint-disable max-len */ 13 //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects. 14 /* eslint-enable max-len */ 15 //>>docs: https://api.jqueryui.com/category/effects-core/ 16 //>>demos: https://jqueryui.com/effect/ 17 18 ( function( factory ) { 19 "use strict"; 20 21 if ( typeof define === "function" && define.amd ) { 22 23 // AMD. Register as an anonymous module. 24 define( [ 25 "jquery", 26 "./jquery-var-for-color", 27 "./vendor/jquery-color/jquery.color", 28 "./version" 29 ], factory ); 30 } else { 31 32 // Browser globals 33 factory( jQuery ); 34 } 35 } )( function( $ ) { 36 "use strict"; 37 38 var dataSpace = "ui-effects-", 39 dataSpaceStyle = "ui-effects-style", 40 dataSpaceAnimated = "ui-effects-animated"; 41 42 $.effects = { 43 effect: {} 44 }; 45 46 /******************************************************************************/ 47 /****************************** CLASS ANIMATIONS ******************************/ 48 /******************************************************************************/ 49 ( function() { 50 51 var classAnimationActions = [ "add", "remove", "toggle" ], 52 shorthandStyles = { 53 border: 1, 54 borderBottom: 1, 55 borderColor: 1, 56 borderLeft: 1, 57 borderRight: 1, 58 borderTop: 1, 59 borderWidth: 1, 60 margin: 1, 61 padding: 1 62 }; 63 64 $.each( 65 [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], 66 function( _, prop ) { 67 $.fx.step[ prop ] = function( fx ) { 68 if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { 69 jQuery.style( fx.elem, prop, fx.end ); 70 fx.setAttr = true; 71 } 72 }; 73 } 74 ); 75 76 function camelCase( string ) { 77 return string.replace( /-([\da-z])/gi, function( all, letter ) { 78 return letter.toUpperCase(); 79 } ); 80 } 81 82 function getElementStyles( elem ) { 83 var key, len, 84 style = elem.ownerDocument.defaultView ? 85 elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : 86 elem.currentStyle, 87 styles = {}; 88 89 if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { 90 len = style.length; 91 while ( len-- ) { 92 key = style[ len ]; 93 if ( typeof style[ key ] === "string" ) { 94 styles[ camelCase( key ) ] = style[ key ]; 95 } 96 } 97 98 // Support: Opera, IE <9 99 } else { 100 for ( key in style ) { 101 if ( typeof style[ key ] === "string" ) { 102 styles[ key ] = style[ key ]; 103 } 104 } 105 } 106 107 return styles; 108 } 109 110 function styleDifference( oldStyle, newStyle ) { 111 var diff = {}, 112 name, value; 113 114 for ( name in newStyle ) { 115 value = newStyle[ name ]; 116 if ( oldStyle[ name ] !== value ) { 117 if ( !shorthandStyles[ name ] ) { 118 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { 119 diff[ name ] = value; 120 } 121 } 122 } 123 } 124 125 return diff; 126 } 127 128 // Support: jQuery <1.8 129 if ( !$.fn.addBack ) { 130 $.fn.addBack = function( selector ) { 131 return this.add( selector == null ? 132 this.prevObject : this.prevObject.filter( selector ) 133 ); 134 }; 135 } 136 137 $.effects.animateClass = function( value, duration, easing, callback ) { 138 var o = $.speed( duration, easing, callback ); 139 140 return this.queue( function() { 141 var animated = $( this ), 142 baseClass = animated.attr( "class" ) || "", 143 applyClassChange, 144 allAnimations = o.children ? animated.find( "*" ).addBack() : animated; 145 146 // Map the animated objects to store the original styles. 147 allAnimations = allAnimations.map( function() { 148 var el = $( this ); 149 return { 150 el: el, 151 start: getElementStyles( this ) 152 }; 153 } ); 154 155 // Apply class change 156 applyClassChange = function() { 157 $.each( classAnimationActions, function( i, action ) { 158 if ( value[ action ] ) { 159 animated[ action + "Class" ]( value[ action ] ); 160 } 161 } ); 162 }; 163 applyClassChange(); 164 165 // Map all animated objects again - calculate new styles and diff 166 allAnimations = allAnimations.map( function() { 167 this.end = getElementStyles( this.el[ 0 ] ); 168 this.diff = styleDifference( this.start, this.end ); 169 return this; 170 } ); 171 172 // Apply original class 173 animated.attr( "class", baseClass ); 174 175 // Map all animated objects again - this time collecting a promise 176 allAnimations = allAnimations.map( function() { 177 var styleInfo = this, 178 dfd = $.Deferred(), 179 opts = $.extend( {}, o, { 180 queue: false, 181 complete: function() { 182 dfd.resolve( styleInfo ); 183 } 184 } ); 185 186 this.el.animate( this.diff, opts ); 187 return dfd.promise(); 188 } ); 189 190 // Once all animations have completed: 191 $.when.apply( $, allAnimations.get() ).done( function() { 192 193 // Set the final class 194 applyClassChange(); 195 196 // For each animated element, 197 // clear all css properties that were animated 198 $.each( arguments, function() { 199 var el = this.el; 200 $.each( this.diff, function( key ) { 201 el.css( key, "" ); 202 } ); 203 } ); 204 205 // This is guarnteed to be there if you use jQuery.speed() 206 // it also handles dequeuing the next anim... 207 o.complete.call( animated[ 0 ] ); 208 } ); 209 } ); 210 }; 211 212 $.fn.extend( { 213 addClass: ( function( orig ) { 214 return function( classNames, speed, easing, callback ) { 215 return speed ? 216 $.effects.animateClass.call( this, 217 { add: classNames }, speed, easing, callback ) : 218 orig.apply( this, arguments ); 219 }; 220 } )( $.fn.addClass ), 221 222 removeClass: ( function( orig ) { 223 return function( classNames, speed, easing, callback ) { 224 return arguments.length > 1 ? 225 $.effects.animateClass.call( this, 226 { remove: classNames }, speed, easing, callback ) : 227 orig.apply( this, arguments ); 228 }; 229 } )( $.fn.removeClass ), 230 231 toggleClass: ( function( orig ) { 232 return function( classNames, force, speed, easing, callback ) { 233 if ( typeof force === "boolean" || force === undefined ) { 234 if ( !speed ) { 235 236 // Without speed parameter 237 return orig.apply( this, arguments ); 238 } else { 239 return $.effects.animateClass.call( this, 240 ( force ? { add: classNames } : { remove: classNames } ), 241 speed, easing, callback ); 242 } 243 } else { 244 245 // Without force parameter 246 return $.effects.animateClass.call( this, 247 { toggle: classNames }, force, speed, easing ); 248 } 249 }; 250 } )( $.fn.toggleClass ), 251 252 switchClass: function( remove, add, speed, easing, callback ) { 253 return $.effects.animateClass.call( this, { 254 add: add, 255 remove: remove 256 }, speed, easing, callback ); 257 } 258 } ); 259 260 } )(); 261 262 /******************************************************************************/ 263 /*********************************** EFFECTS **********************************/ 264 /******************************************************************************/ 265 266 ( function() { 267 268 if ( $.expr && $.expr.pseudos && $.expr.pseudos.animated ) { 269 $.expr.pseudos.animated = ( function( orig ) { 270 return function( elem ) { 271 return !!$( elem ).data( dataSpaceAnimated ) || orig( elem ); 272 }; 273 } )( $.expr.pseudos.animated ); 274 } 275 276 if ( $.uiBackCompat !== false ) { 277 $.extend( $.effects, { 278 279 // Saves a set of properties in a data storage 280 save: function( element, set ) { 281 var i = 0, length = set.length; 282 for ( ; i < length; i++ ) { 283 if ( set[ i ] !== null ) { 284 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); 285 } 286 } 287 }, 288 289 // Restores a set of previously saved properties from a data storage 290 restore: function( element, set ) { 291 var val, i = 0, length = set.length; 292 for ( ; i < length; i++ ) { 293 if ( set[ i ] !== null ) { 294 val = element.data( dataSpace + set[ i ] ); 295 element.css( set[ i ], val ); 296 } 297 } 298 }, 299 300 setMode: function( el, mode ) { 301 if ( mode === "toggle" ) { 302 mode = el.is( ":hidden" ) ? "show" : "hide"; 303 } 304 return mode; 305 }, 306 307 // Wraps the element around a wrapper that copies position properties 308 createWrapper: function( element ) { 309 310 // If the element is already wrapped, return it 311 if ( element.parent().is( ".ui-effects-wrapper" ) ) { 312 return element.parent(); 313 } 314 315 // Wrap the element 316 var props = { 317 width: element.outerWidth( true ), 318 height: element.outerHeight( true ), 319 "float": element.css( "float" ) 320 }, 321 wrapper = $( "<div></div>" ) 322 .addClass( "ui-effects-wrapper" ) 323 .css( { 324 fontSize: "100%", 325 background: "transparent", 326 border: "none", 327 margin: 0, 328 padding: 0 329 } ), 330 331 // Store the size in case width/height are defined in % - Fixes #5245 332 size = { 333 width: element.width(), 334 height: element.height() 335 }, 336 active = document.activeElement; 337 338 // Support: Firefox 339 // Firefox incorrectly exposes anonymous content 340 // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 341 try { 342 // eslint-disable-next-line no-unused-expressions 343 active.id; 344 } catch ( e ) { 345 active = document.body; 346 } 347 348 element.wrap( wrapper ); 349 350 // Fixes #7595 - Elements lose focus when wrapped. 351 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { 352 $( active ).trigger( "focus" ); 353 } 354 355 // Hotfix for jQuery 1.4 since some change in wrap() seems to actually 356 // lose the reference to the wrapped element 357 wrapper = element.parent(); 358 359 // Transfer positioning properties to the wrapper 360 if ( element.css( "position" ) === "static" ) { 361 wrapper.css( { position: "relative" } ); 362 element.css( { position: "relative" } ); 363 } else { 364 $.extend( props, { 365 position: element.css( "position" ), 366 zIndex: element.css( "z-index" ) 367 } ); 368 $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) { 369 props[ pos ] = element.css( pos ); 370 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { 371 props[ pos ] = "auto"; 372 } 373 } ); 374 element.css( { 375 position: "relative", 376 top: 0, 377 left: 0, 378 right: "auto", 379 bottom: "auto" 380 } ); 381 } 382 element.css( size ); 383 384 return wrapper.css( props ).show(); 385 }, 386 387 removeWrapper: function( element ) { 388 var active = document.activeElement; 389 390 if ( element.parent().is( ".ui-effects-wrapper" ) ) { 391 element.parent().replaceWith( element ); 392 393 // Fixes #7595 - Elements lose focus when wrapped. 394 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { 395 $( active ).trigger( "focus" ); 396 } 397 } 398 399 return element; 400 } 401 } ); 402 } 403 404 $.extend( $.effects, { 405 version: "1.13.3", 406 407 define: function( name, mode, effect ) { 408 if ( !effect ) { 409 effect = mode; 410 mode = "effect"; 411 } 412 413 $.effects.effect[ name ] = effect; 414 $.effects.effect[ name ].mode = mode; 415 416 return effect; 417 }, 418 419 scaledDimensions: function( element, percent, direction ) { 420 if ( percent === 0 ) { 421 return { 422 height: 0, 423 width: 0, 424 outerHeight: 0, 425 outerWidth: 0 426 }; 427 } 428 429 var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1, 430 y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1; 431 432 return { 433 height: element.height() * y, 434 width: element.width() * x, 435 outerHeight: element.outerHeight() * y, 436 outerWidth: element.outerWidth() * x 437 }; 438 439 }, 440 441 clipToBox: function( animation ) { 442 return { 443 width: animation.clip.right - animation.clip.left, 444 height: animation.clip.bottom - animation.clip.top, 445 left: animation.clip.left, 446 top: animation.clip.top 447 }; 448 }, 449 450 // Injects recently queued functions to be first in line (after "inprogress") 451 unshift: function( element, queueLength, count ) { 452 var queue = element.queue(); 453 454 if ( queueLength > 1 ) { 455 queue.splice.apply( queue, 456 [ 1, 0 ].concat( queue.splice( queueLength, count ) ) ); 457 } 458 element.dequeue(); 459 }, 460 461 saveStyle: function( element ) { 462 element.data( dataSpaceStyle, element[ 0 ].style.cssText ); 463 }, 464 465 restoreStyle: function( element ) { 466 element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || ""; 467 element.removeData( dataSpaceStyle ); 468 }, 469 470 mode: function( element, mode ) { 471 var hidden = element.is( ":hidden" ); 472 473 if ( mode === "toggle" ) { 474 mode = hidden ? "show" : "hide"; 475 } 476 if ( hidden ? mode === "hide" : mode === "show" ) { 477 mode = "none"; 478 } 479 return mode; 480 }, 481 482 // Translates a [top,left] array into a baseline value 483 getBaseline: function( origin, original ) { 484 var y, x; 485 486 switch ( origin[ 0 ] ) { 487 case "top": 488 y = 0; 489 break; 490 case "middle": 491 y = 0.5; 492 break; 493 case "bottom": 494 y = 1; 495 break; 496 default: 497 y = origin[ 0 ] / original.height; 498 } 499 500 switch ( origin[ 1 ] ) { 501 case "left": 502 x = 0; 503 break; 504 case "center": 505 x = 0.5; 506 break; 507 case "right": 508 x = 1; 509 break; 510 default: 511 x = origin[ 1 ] / original.width; 512 } 513 514 return { 515 x: x, 516 y: y 517 }; 518 }, 519 520 // Creates a placeholder element so that the original element can be made absolute 521 createPlaceholder: function( element ) { 522 var placeholder, 523 cssPosition = element.css( "position" ), 524 position = element.position(); 525 526 // Lock in margins first to account for form elements, which 527 // will change margin if you explicitly set height 528 // see: https://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380 529 // Support: Safari 530 element.css( { 531 marginTop: element.css( "marginTop" ), 532 marginBottom: element.css( "marginBottom" ), 533 marginLeft: element.css( "marginLeft" ), 534 marginRight: element.css( "marginRight" ) 535 } ) 536 .outerWidth( element.outerWidth() ) 537 .outerHeight( element.outerHeight() ); 538 539 if ( /^(static|relative)/.test( cssPosition ) ) { 540 cssPosition = "absolute"; 541 542 placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( { 543 544 // Convert inline to inline block to account for inline elements 545 // that turn to inline block based on content (like img) 546 display: /^(inline|ruby)/.test( element.css( "display" ) ) ? 547 "inline-block" : 548 "block", 549 visibility: "hidden", 550 551 // Margins need to be set to account for margin collapse 552 marginTop: element.css( "marginTop" ), 553 marginBottom: element.css( "marginBottom" ), 554 marginLeft: element.css( "marginLeft" ), 555 marginRight: element.css( "marginRight" ), 556 "float": element.css( "float" ) 557 } ) 558 .outerWidth( element.outerWidth() ) 559 .outerHeight( element.outerHeight() ) 560 .addClass( "ui-effects-placeholder" ); 561 562 element.data( dataSpace + "placeholder", placeholder ); 563 } 564 565 element.css( { 566 position: cssPosition, 567 left: position.left, 568 top: position.top 569 } ); 570 571 return placeholder; 572 }, 573 574 removePlaceholder: function( element ) { 575 var dataKey = dataSpace + "placeholder", 576 placeholder = element.data( dataKey ); 577 578 if ( placeholder ) { 579 placeholder.remove(); 580 element.removeData( dataKey ); 581 } 582 }, 583 584 // Removes a placeholder if it exists and restores 585 // properties that were modified during placeholder creation 586 cleanUp: function( element ) { 587 $.effects.restoreStyle( element ); 588 $.effects.removePlaceholder( element ); 589 }, 590 591 setTransition: function( element, list, factor, value ) { 592 value = value || {}; 593 $.each( list, function( i, x ) { 594 var unit = element.cssUnit( x ); 595 if ( unit[ 0 ] > 0 ) { 596 value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; 597 } 598 } ); 599 return value; 600 } 601 } ); 602 603 // Return an effect options object for the given parameters: 604 function _normalizeArguments( effect, options, speed, callback ) { 605 606 // Allow passing all options as the first parameter 607 if ( $.isPlainObject( effect ) ) { 608 options = effect; 609 effect = effect.effect; 610 } 611 612 // Convert to an object 613 effect = { effect: effect }; 614 615 // Catch (effect, null, ...) 616 if ( options == null ) { 617 options = {}; 618 } 619 620 // Catch (effect, callback) 621 if ( typeof options === "function" ) { 622 callback = options; 623 speed = null; 624 options = {}; 625 } 626 627 // Catch (effect, speed, ?) 628 if ( typeof options === "number" || $.fx.speeds[ options ] ) { 629 callback = speed; 630 speed = options; 631 options = {}; 632 } 633 634 // Catch (effect, options, callback) 635 if ( typeof speed === "function" ) { 636 callback = speed; 637 speed = null; 638 } 639 640 // Add options to effect 641 if ( options ) { 642 $.extend( effect, options ); 643 } 644 645 speed = speed || options.duration; 646 effect.duration = $.fx.off ? 0 : 647 typeof speed === "number" ? speed : 648 speed in $.fx.speeds ? $.fx.speeds[ speed ] : 649 $.fx.speeds._default; 650 651 effect.complete = callback || options.complete; 652 653 return effect; 654 } 655 656 function standardAnimationOption( option ) { 657 658 // Valid standard speeds (nothing, number, named speed) 659 if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { 660 return true; 661 } 662 663 // Invalid strings - treat as "normal" speed 664 if ( typeof option === "string" && !$.effects.effect[ option ] ) { 665 return true; 666 } 667 668 // Complete callback 669 if ( typeof option === "function" ) { 670 return true; 671 } 672 673 // Options hash (but not naming an effect) 674 if ( typeof option === "object" && !option.effect ) { 675 return true; 676 } 677 678 // Didn't match any standard API 679 return false; 680 } 681 682 $.fn.extend( { 683 effect: function( /* effect, options, speed, callback */ ) { 684 var args = _normalizeArguments.apply( this, arguments ), 685 effectMethod = $.effects.effect[ args.effect ], 686 defaultMode = effectMethod.mode, 687 queue = args.queue, 688 queueName = queue || "fx", 689 complete = args.complete, 690 mode = args.mode, 691 modes = [], 692 prefilter = function( next ) { 693 var el = $( this ), 694 normalizedMode = $.effects.mode( el, mode ) || defaultMode; 695 696 // Sentinel for duck-punching the :animated pseudo-selector 697 el.data( dataSpaceAnimated, true ); 698 699 // Save effect mode for later use, 700 // we can't just call $.effects.mode again later, 701 // as the .show() below destroys the initial state 702 modes.push( normalizedMode ); 703 704 // See $.uiBackCompat inside of run() for removal of defaultMode in 1.14 705 if ( defaultMode && ( normalizedMode === "show" || 706 ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) { 707 el.show(); 708 } 709 710 if ( !defaultMode || normalizedMode !== "none" ) { 711 $.effects.saveStyle( el ); 712 } 713 714 if ( typeof next === "function" ) { 715 next(); 716 } 717 }; 718 719 if ( $.fx.off || !effectMethod ) { 720 721 // Delegate to the original method (e.g., .show()) if possible 722 if ( mode ) { 723 return this[ mode ]( args.duration, complete ); 724 } else { 725 return this.each( function() { 726 if ( complete ) { 727 complete.call( this ); 728 } 729 } ); 730 } 731 } 732 733 function run( next ) { 734 var elem = $( this ); 735 736 function cleanup() { 737 elem.removeData( dataSpaceAnimated ); 738 739 $.effects.cleanUp( elem ); 740 741 if ( args.mode === "hide" ) { 742 elem.hide(); 743 } 744 745 done(); 746 } 747 748 function done() { 749 if ( typeof complete === "function" ) { 750 complete.call( elem[ 0 ] ); 751 } 752 753 if ( typeof next === "function" ) { 754 next(); 755 } 756 } 757 758 // Override mode option on a per element basis, 759 // as toggle can be either show or hide depending on element state 760 args.mode = modes.shift(); 761 762 if ( $.uiBackCompat !== false && !defaultMode ) { 763 if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { 764 765 // Call the core method to track "olddisplay" properly 766 elem[ mode ](); 767 done(); 768 } else { 769 effectMethod.call( elem[ 0 ], args, done ); 770 } 771 } else { 772 if ( args.mode === "none" ) { 773 774 // Call the core method to track "olddisplay" properly 775 elem[ mode ](); 776 done(); 777 } else { 778 effectMethod.call( elem[ 0 ], args, cleanup ); 779 } 780 } 781 } 782 783 // Run prefilter on all elements first to ensure that 784 // any showing or hiding happens before placeholder creation, 785 // which ensures that any layout changes are correctly captured. 786 return queue === false ? 787 this.each( prefilter ).each( run ) : 788 this.queue( queueName, prefilter ).queue( queueName, run ); 789 }, 790 791 show: ( function( orig ) { 792 return function( option ) { 793 if ( standardAnimationOption( option ) ) { 794 return orig.apply( this, arguments ); 795 } else { 796 var args = _normalizeArguments.apply( this, arguments ); 797 args.mode = "show"; 798 return this.effect.call( this, args ); 799 } 800 }; 801 } )( $.fn.show ), 802 803 hide: ( function( orig ) { 804 return function( option ) { 805 if ( standardAnimationOption( option ) ) { 806 return orig.apply( this, arguments ); 807 } else { 808 var args = _normalizeArguments.apply( this, arguments ); 809 args.mode = "hide"; 810 return this.effect.call( this, args ); 811 } 812 }; 813 } )( $.fn.hide ), 814 815 toggle: ( function( orig ) { 816 return function( option ) { 817 if ( standardAnimationOption( option ) || typeof option === "boolean" ) { 818 return orig.apply( this, arguments ); 819 } else { 820 var args = _normalizeArguments.apply( this, arguments ); 821 args.mode = "toggle"; 822 return this.effect.call( this, args ); 823 } 824 }; 825 } )( $.fn.toggle ), 826 827 cssUnit: function( key ) { 828 var style = this.css( key ), 829 val = []; 830 831 $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { 832 if ( style.indexOf( unit ) > 0 ) { 833 val = [ parseFloat( style ), unit ]; 834 } 835 } ); 836 return val; 837 }, 838 839 cssClip: function( clipObj ) { 840 if ( clipObj ) { 841 return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + 842 clipObj.bottom + "px " + clipObj.left + "px)" ); 843 } 844 return parseClip( this.css( "clip" ), this ); 845 }, 846 847 transfer: function( options, done ) { 848 var element = $( this ), 849 target = $( options.to ), 850 targetFixed = target.css( "position" ) === "fixed", 851 body = $( "body" ), 852 fixTop = targetFixed ? body.scrollTop() : 0, 853 fixLeft = targetFixed ? body.scrollLeft() : 0, 854 endPosition = target.offset(), 855 animation = { 856 top: endPosition.top - fixTop, 857 left: endPosition.left - fixLeft, 858 height: target.innerHeight(), 859 width: target.innerWidth() 860 }, 861 startPosition = element.offset(), 862 transfer = $( "<div class='ui-effects-transfer'></div>" ); 863 864 transfer 865 .appendTo( "body" ) 866 .addClass( options.className ) 867 .css( { 868 top: startPosition.top - fixTop, 869 left: startPosition.left - fixLeft, 870 height: element.innerHeight(), 871 width: element.innerWidth(), 872 position: targetFixed ? "fixed" : "absolute" 873 } ) 874 .animate( animation, options.duration, options.easing, function() { 875 transfer.remove(); 876 if ( typeof done === "function" ) { 877 done(); 878 } 879 } ); 880 } 881 } ); 882 883 function parseClip( str, element ) { 884 var outerWidth = element.outerWidth(), 885 outerHeight = element.outerHeight(), 886 clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/, 887 values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ]; 888 889 return { 890 top: parseFloat( values[ 1 ] ) || 0, 891 right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ), 892 bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ), 893 left: parseFloat( values[ 4 ] ) || 0 894 }; 895 } 896 897 $.fx.step.clip = function( fx ) { 898 if ( !fx.clipInit ) { 899 fx.start = $( fx.elem ).cssClip(); 900 if ( typeof fx.end === "string" ) { 901 fx.end = parseClip( fx.end, fx.elem ); 902 } 903 fx.clipInit = true; 904 } 905 906 $( fx.elem ).cssClip( { 907 top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top, 908 right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right, 909 bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom, 910 left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left 911 } ); 912 }; 913 914 } )(); 915 916 /******************************************************************************/ 917 /*********************************** EASING ***********************************/ 918 /******************************************************************************/ 919 920 ( function() { 921 922 // Based on easing equations from Robert Penner (http://robertpenner.com/easing) 923 924 var baseEasings = {}; 925 926 $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { 927 baseEasings[ name ] = function( p ) { 928 return Math.pow( p, i + 2 ); 929 }; 930 } ); 931 932 $.extend( baseEasings, { 933 Sine: function( p ) { 934 return 1 - Math.cos( p * Math.PI / 2 ); 935 }, 936 Circ: function( p ) { 937 return 1 - Math.sqrt( 1 - p * p ); 938 }, 939 Elastic: function( p ) { 940 return p === 0 || p === 1 ? p : 941 -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 ); 942 }, 943 Back: function( p ) { 944 return p * p * ( 3 * p - 2 ); 945 }, 946 Bounce: function( p ) { 947 var pow2, 948 bounce = 4; 949 950 while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} 951 return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); 952 } 953 } ); 954 955 $.each( baseEasings, function( name, easeIn ) { 956 $.easing[ "easeIn" + name ] = easeIn; 957 $.easing[ "easeOut" + name ] = function( p ) { 958 return 1 - easeIn( 1 - p ); 959 }; 960 $.easing[ "easeInOut" + name ] = function( p ) { 961 return p < 0.5 ? 962 easeIn( p * 2 ) / 2 : 963 1 - easeIn( p * -2 + 2 ) / 2; 964 }; 965 } ); 966 967 } )(); 968 969 return $.effects; 970 971 } );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu Nov 21 08:20:01 2024 | Cross-referenced by PHPXref |