1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default 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();
                }
            }
        }
    });

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    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

  3. #3
    Sencha User
    Join Date
    Sep 2007
    Location
    Tulsa, Oklahoma
    Posts
    178
    Vote Rating
    1
    ckr is on a distinguished road

      0  

    Default


    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).

    Here
    Thanks!
    Chuck

  4. #4
    Touch Premium Member
    Join Date
    Mar 2008
    Posts
    5
    Vote Rating
    0
    gugman is on a distinguished road

      0  

    Default


    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
    });

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    Thanks for that hint. I've updated the code in post #1.

  6. #6
    Sencha User
    Join Date
    Sep 2007
    Location
    Tulsa, Oklahoma
    Posts
    178
    Vote Rating
    1
    ckr is on a distinguished road

      0  

    Default


    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

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    OK, try the latest code. It now uses

    Code:
                    n.fadeIn({
                        callback: function() {
                            n.setStyle({
                                position: '',
                            });
                        }
                    });
    To fade the new Panel in which restores positioning to the default.

  8. #8
    Sencha User
    Join Date
    Sep 2007
    Location
    Tulsa, Oklahoma
    Posts
    178
    Vote Rating
    1
    ckr is on a distinguished road

      0  

    Default


    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

  9. #9
    Sencha User
    Join Date
    Sep 2007
    Location
    Tulsa, Oklahoma
    Posts
    178
    Vote Rating
    1
    ckr is on a distinguished road

      0  

    Default


    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

  10. #10
    Touch Premium Member
    Join Date
    Mar 2008
    Posts
    5
    Vote Rating
    0
    gugman is on a distinguished road

      0  

    Default


    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:
    Code:
    n.fadeIn({
    callback: function() {
    n.setStyle({
    position: 'relative',
    });
    }
    });

    More information on this and other IE related Opacity/Positioning bugs:

    http://www.makemineatriple.com/2007/...y_text_issues/

    http://joseph.randomnetworks.com/arc...t-explorer-ie/