watrboy00
8 Jun 2010, 7:28 AM
/**
* @cfg {String/Number} activeItem
* A string component id or the numeric index of the component that should be initially activated within the
* container's layout on render. For example, activeItem: 'item-1' or activeItem: 0 (index 0 = the first
* item in the container's collection). activeItem only applies to layout styles that can display
* items one at a time (like {@link Ext.layout.CardLayout} and
* {@link Ext.layout.FitLayout}). Related to {@link Ext.layout.ContainerLayout#activeItem}.
*/
Ext.Container has activeItem config and it states that the specified activeItem will be initially activated within a container's layout on render. I see a couple problems here.
First...Ext.Carousel extends from Ext.Container and in its afterRender function sets the active item but defaults to the first item instead of first checking to see if activeItem exists and setting it as active if so.
afterRender : function() {
Ext.Carousel.superclass.afterRender.call(this);
this.scroller.on({
touchend: this.onTouchEnd,
scrollend: this.onScrollEnd,
scope: this
});
if (this.items.items.length) {
this.setActiveItem(this.items.items[0]);
}
}
Second: I think some logic is backwards or could be better. If the docs say that the layout will set the active item on render then why is it that the carousel is setting the active item? Instead of setting it in the after render function of carousel why wouldn't the layout do the heavy lifting itself? Then all the carousel would have to do is specific actions that need to take place after and item has been activated.
There could be huge code savings if this were mimicked across the framework and abstracted to the layout where it should be.
* @cfg {String/Number} activeItem
* A string component id or the numeric index of the component that should be initially activated within the
* container's layout on render. For example, activeItem: 'item-1' or activeItem: 0 (index 0 = the first
* item in the container's collection). activeItem only applies to layout styles that can display
* items one at a time (like {@link Ext.layout.CardLayout} and
* {@link Ext.layout.FitLayout}). Related to {@link Ext.layout.ContainerLayout#activeItem}.
*/
Ext.Container has activeItem config and it states that the specified activeItem will be initially activated within a container's layout on render. I see a couple problems here.
First...Ext.Carousel extends from Ext.Container and in its afterRender function sets the active item but defaults to the first item instead of first checking to see if activeItem exists and setting it as active if so.
afterRender : function() {
Ext.Carousel.superclass.afterRender.call(this);
this.scroller.on({
touchend: this.onTouchEnd,
scrollend: this.onScrollEnd,
scope: this
});
if (this.items.items.length) {
this.setActiveItem(this.items.items[0]);
}
}
Second: I think some logic is backwards or could be better. If the docs say that the layout will set the active item on render then why is it that the carousel is setting the active item? Instead of setting it in the after render function of carousel why wouldn't the layout do the heavy lifting itself? Then all the carousel would have to do is specific actions that need to take place after and item has been activated.
There could be huge code savings if this were mimicked across the framework and abstracted to the layout where it should be.