From ff9c545f0968b852100a161f0f6950ad9cf81dd6 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 5 May 2011 09:33:10 +0900 Subject: [PATCH 1/5] Effects (size): Size effect should swap from/to on show, and restore more properties. Fixed #7041 - Toggle size effect demo not working. --- ui/jquery.effects.scale.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 8f25ca9a8a7..dee64f572ff 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -69,7 +69,7 @@ $.effects.effect.scale = function( o ) { options.restore = true; } - options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); + options.from = o.from; options.to = { height: original.height * factor.y, width: original.width * factor.x @@ -97,7 +97,7 @@ $.effects.effect.size = function( o ) { return this.queue( function() { // Create element var el = $( this ), - props = [ 'position', 'top', 'bottom', 'left', 'right', 'width', 'height', 'overflow', 'opacity' ], + props0 = [ 'position', 'top', 'bottom', 'left', 'right', 'width', 'height', 'overflow', 'opacity' ], // Always restore props1 = [ 'position', 'top', 'bottom', 'left', 'right', 'overflow', 'opacity' ], @@ -117,10 +117,18 @@ $.effects.effect.size = function( o ) { height: el.height(), width: el.width() }, - baseline, factor; - - el.from = o.from || original; - el.to = o.to || original; + baseline, factor, + props = restore ? props0 : props1; + + if (mode == 'show') { + el.from = o.to; + el.to = o.from; + } else { + el.from = o.from; + el.to = o.to; + } + el.from = el.from || original; + el.to = el.to || original; // Adjust if (origin) { // Calculate baseline shifts @@ -166,13 +174,13 @@ $.effects.effect.size = function( o ) { // Vertical props scaling if ( factor.from.y != factor.to.y ) { - props = props.concat( cProps ); + props = props.concat(cProps).concat(props2); el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); }; }; - $.effects.save( el, restore ? props : props1 ); + $.effects.save( el, props ); el.show(); $.effects.createWrapper( el ); el.css( 'overflow', 'hidden' ).css( el.from ); @@ -183,7 +191,7 @@ $.effects.effect.size = function( o ) { // Add margins/font-size vProps = vProps.concat([ 'marginTop', 'marginBottom' ]).concat(cProps); hProps = hProps.concat([ 'marginLeft', 'marginRight' ]); - props2 = props.concat(vProps).concat(hProps); + props2 = props0.concat(vProps).concat(hProps); el.find( "*[width]" ).each( function(){ var child = $( this ), @@ -236,7 +244,7 @@ $.effects.effect.size = function( o ) { if( mode == 'hide' ) { el.hide(); } - $.effects.restore( el, restore ? props : props1 ); + $.effects.restore( el, props ); $.effects.removeWrapper( el ); $.isFunction( o.complete ) && o.complete.apply( this, arguments ); // Callback el.dequeue(); From bc50fe3ff5c68bc68402fbe157d88db9ae8db95b Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 5 May 2011 12:27:02 +0900 Subject: [PATCH 2/5] Effects (size): Code cleanup. * Separete `scale` effect's problem. * Clearify the default value of `from` and `to`. * Follow http://docs.jquery.com/JQuery_Core_Style_Guidelines. --- ui/jquery.effects.scale.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index dee64f572ff..4b4143c2665 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -69,7 +69,7 @@ $.effects.effect.scale = function( o ) { options.restore = true; } - options.from = o.from; + options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); options.to = { height: original.height * factor.y, width: original.width * factor.x @@ -120,15 +120,13 @@ $.effects.effect.size = function( o ) { baseline, factor, props = restore ? props0 : props1; - if (mode == 'show') { - el.from = o.to; - el.to = o.from; + if ( o.mode === "toggle" && mode === "show" ) { + el.from = o.to || { height: 0, width: 0 }; + el.to = o.from || original; } else { - el.from = o.from; - el.to = o.to; + el.from = o.from || original; + el.to = o.to || { height: 0, width: 0 }; } - el.from = el.from || original; - el.to = el.to || original; // Adjust if (origin) { // Calculate baseline shifts From 825791d6ec94a9c6a65f372084af7a3c6d6c82c1 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 5 May 2011 20:22:19 +0900 Subject: [PATCH 3/5] Effects (size): Every effect should works correctly with hidden element. --- ui/jquery.effects.scale.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 4b4143c2665..f56d729ed5d 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -120,13 +120,9 @@ $.effects.effect.size = function( o ) { baseline, factor, props = restore ? props0 : props1; - if ( o.mode === "toggle" && mode === "show" ) { - el.from = o.to || { height: 0, width: 0 }; - el.to = o.from || original; - } else { - el.from = o.from || original; - el.to = o.to || { height: 0, width: 0 }; - } + var zero = { height: 0, width: 0 }; + el.from = o.from || ( mode === "show" ? zero : original ); + el.to = o.to || ( mode === "hide" ? zero : original ); // Adjust if (origin) { // Calculate baseline shifts From 416fde523f6c5b888abc1000affa6b3657a1baf4 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 12 May 2011 23:13:36 +0900 Subject: [PATCH 4/5] Effects (size): Simplify my changes for this "toggle" branch. --- ui/jquery.effects.scale.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index f56d729ed5d..24cb3231e09 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -118,11 +118,16 @@ $.effects.effect.size = function( o ) { width: el.width() }, baseline, factor, - props = restore ? props0 : props1; - - var zero = { height: 0, width: 0 }; - el.from = o.from || ( mode === "show" ? zero : original ); - el.to = o.to || ( mode === "hide" ? zero : original ); + props = restore ? props0 : props1, + zero = { height: 0, width: 0 }; + + if ( o.mode === "toggle" && mode === "show" ) { + el.from = o.to || zero; + el.to = o.from || original; + } else { + el.from = o.from || original; + el.to = o.to || zero; + } // Adjust if (origin) { // Calculate baseline shifts From afcdbc9b2f8fb009af91f715cc6b7de67619bc19 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Fri, 13 May 2011 06:10:53 +0900 Subject: [PATCH 5/5] Effects (size): Add direction detection in both side. --- ui/jquery.effects.scale.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 24cb3231e09..d1637c5d6fa 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -125,8 +125,8 @@ $.effects.effect.size = function( o ) { el.from = o.to || zero; el.to = o.from || original; } else { - el.from = o.from || original; - el.to = o.to || zero; + el.from = o.from || ( mode === "show" ? zero : original ); + el.to = o.to || ( mode === "hide" ? zero : original ); } // Adjust