標籤:
(function( $, undefined ) { //-----閉包,熟了不能再熟了$.effects.effect.transfer = function( o, done ) {var elem = $( this ),target = $( o.to ), //最終移到到的目標元素targetFixed = target.css( "position" ) === "fixed",body = $("body"),fixTop = targetFixed ? body.scrollTop() : 0,fixLeft = targetFixed ? body.scrollLeft() : 0,endPosition = target.offset(),animation = {top: endPosition.top - fixTop ,left: endPosition.left - fixLeft ,height: target.innerHeight(),width: target.innerWidth()},startPosition = elem.offset(),transfer = $( '<div class="ui-effects-transfer"></div>' ) //--------------構造動畫元素.appendTo( document.body ).addClass( o.className ).css({top: startPosition.top - fixTop ,left: startPosition.left - fixLeft ,height: elem.innerHeight(),width: elem.innerWidth(),position: targetFixed ? "fixed" : "absolute" //---------------定位}).animate( animation, o.duration, o.easing, function() {transfer.remove(); //--------------- 動畫結束移除done(); //---動畫完成});};})(jQuery);
jqueryui動畫一窺之jquery.ui.effect-transfer.js