-
16 Sep 2008 6:47 AM #1
CardLayout override which fades the cards in/out
CardLayout override which fades the cards in/out
You need to use layoutConfig: { animate: true } to make it animate.
Code:Ext.override(Ext.layout.CardLayout, { setActiveItem : function(item){ item = this.container.getComponent(item); if(this.activeItem != item){ if (item.rendered && this.animate) { Ext.Fx.syncFx(); // Correct top position of card because they have to occupy the same space // during animation. var n = item.getEl(); n.setStyle({ position: 'absolute', top: this.container.getLayoutTarget().getPadding('t') + 'px' }); if (this.activeItem) { this.activeItem.getEl().fadeOut({ useDisplay:true, callback: Ext.Component.prototype.hide, scope: this.activeItem }); } this.activeItem = item; item.show(); this.container.doLayout(); n.fadeIn({ callback: function() { n.setStyle({ position: '' }); } }); Ext.Fx.sequenceFx(); } else { if(this.activeItem){ this.activeItem.hide(); } this.activeItem = item; item.show(); this.container.doLayout(); } } } });Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
18 Sep 2008 4:04 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
I experimented a while back with fades for masks. It's a great idea if the objects are rendered.
http://tdg-i.com/img/screencasts/2008-03-13_1656.swf
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
18 Sep 2008 8:07 PM #3
Very nice.
One thing that is strange, is that with IE, after I cycle through my cards once, and then start cycling backwards, the animation quits working. Works fine in FF3, Chrome(beta).
HereThanks!
Chuck
-
18 Sep 2008 9:46 PM #4
This cross-fade CardLayout is fantastic. Thank you Animal.
To get this to work in IE, 'useDisplay:true' needs to be added to the fadeOut config:
Code:this.activeItem.getEl().fadeOut({useDisplay:true,callback: Ext.Component.prototype.hide,scope: this.activeItem});
-
18 Sep 2008 11:50 PM #5
Thanks for that hint. I've updated the code in post #1.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
19 Sep 2008 3:53 AM #6
The fadeIn/fadeOut will work adding useDisplay: true
However, now when you bounce back and forth between the last two panels in my little test, the accordion looses any of the panels that are collapsed at the bottom. You do see them flash for a bit when leaving the accordion card going to the slider card. But when you go back to the accordion card, the panel headers (to expand) do not show up until you collapse the displayed header.
Still very nice effect.Thanks!
Chuck
-
19 Sep 2008 4:51 AM #7
OK, try the latest code. It now uses
To fade the new Panel in which restores positioning to the default.Code:n.fadeIn({ callback: function() { n.setStyle({ position: '', }); } });Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
19 Sep 2008 8:28 AM #8
Appears to have not made a difference.
I will try to look at it in more detail this weekend (real work getting in the way of fun).Thanks!
Chuck
-
22 Sep 2008 5:43 AM #9
Well, was a busy weekend, and did not get to spend much time on this. I did have to clean up the demo a bit (was a bunch of cut and paste examples), and that helped some. However in IE, when paging backwards, it still has a problem (meaning the fade Out/In does not work).
Also, I had to change two lines: this.container.doLayout(); to: this.layout();
With those and your previous changes, everything works perfectly in FF, Chorme (and I imagine others). Only IE is behaving strangely.
Thanks!
Chuck
-
22 Sep 2008 4:51 PM #10
CKR:
I have run into this before with IE. IE requires an element to be positioned in order for filter/opacity to work correctly. Setting position to: ' ' breaks it in IE. See possible fix below which I tested on your sample.
Animal:
I tried setting position to 'relative' on the fadeIn callback and that seems to work:
More information on this and other IE related Opacity/Positioning bugs:Code:n.fadeIn({callback: function() {n.setStyle({position: 'relative',});}});
http://www.makemineatriple.com/2007/...y_text_issues/
http://joseph.randomnetworks.com/arc...t-explorer-ie/


Reply With Quote