Hybrid View

  1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,502
    Vote Rating
    48
    Animal has a spectacular aura about Animal has a spectacular aura about

      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
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,360
    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,502
    Vote Rating
    48
    Animal has a spectacular aura about Animal has a spectacular aura about

      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,502
    Vote Rating
    48
    Animal has a spectacular aura about Animal has a spectacular aura about

      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
    Ext JS Premium Member vishalg's Avatar
    Join Date
    Sep 2007
    Location
    Los Angeles, CA
    Posts
    75
    Vote Rating
    0
    vishalg is on a distinguished road

      0  

    Thumbs up


    Quote Originally Posted by Animal View Post

    Code:
    n.setStyle({
        position: '',
    });
    should remove ',' to use in IE.

    How hard would it be to support different effects ?

    Thanks for this extension animal.