-
4 Aug 2008 8:30 AM #1
Ext.layout.SlideLayout - Sliding Card Layout (Shift Fx)
Ext.layout.SlideLayout - Sliding Card Layout (Shift Fx)
Hey guys,
I had a need for a card panel layout that used slide effects.
See: Live Demo.
Shift fX config can be set through layoutConfig eg:
The code:PHP Code:layoutConfig: {
easing: 'easeOut',
duration: 1,
opacity: .1
}
PHP Code:Ext.layout.SlideLayout = Ext.extend(Ext.layout.FitLayout, {
deferredRender : false,
renderHidden : false,
easing: 'none',
duration: .5,
opacity: 1,
setActiveItem : function(itemInt){
if (typeof(itemInt) == 'string') { itemInt = this.container.items.keys.indexOf(itemInt); }
else if (typeof(itemInt) == 'object') { itemInt = this.container.items.items.indexOf(itemInt); }
var item = this.container.getComponent(itemInt);
if(this.activeItem != item){
if(this.activeItem){
if(item && (!item.rendered || !this.isValidParent(item, this.container))){
this.renderItem(item, itemInt, this.container.getLayoutTarget()); item.show();
}
var s = [this.container.body.getX() - this.container.body.getWidth(), this.container.body.getX() + this.container.body.getWidth()];
this.activeItem.el.shift({ duration: this.duration, easing: this.easing, opacity: this.opacity, x:(this.activeItemNo < itemInt ? s[0] : s[1] )});
item.el.setY(this.container.body.getY());
item.el.setX((this.activeItemNo < itemInt ? s[1] : s[0] ));
item.el.shift({ duration: this.duration, easing: this.easing, opacity: 1, x:this.container.body.getX()});
}
this.activeItemNo = itemInt;
this.activeItem = item;
this.layout();
}
},
renderAll : function(ct, target){
if(this.deferredRender){
this.renderItem(this.activeItem, undefined, target);
}else{
Ext.layout.CardLayout.superclass.renderAll.call(this, ct, target);
}
}
});
Ext.Container.LAYOUTS['slide'] = Ext.layout.SlideLayout;
Last edited by NeonMonk; 1 Jan 2009 at 9:51 PM. Reason: Added live demo link
-
4 Aug 2008 9:42 AM #2
neat.

i tried swapping out TabPanel's CardLayout for a SlideLayout though, and it only worked for the first tab, after which the following error was thrown:
any example / recommended usage?Code:item.el is undefined ... ... [Break on this error] item.el.setY(this.container.body.getY());
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
4 Aug 2008 4:33 PM #3
SlideLayout wasn't originally compatible with deferredRendering..
Code has now been updated so if you try it again mystic it should work fine.
-
4 Aug 2008 6:16 PM #4
alritey. works fine now. good stuff

Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
4 Oct 2008 1:31 PM #5
Thanks!
Chuck
-
6 Oct 2008 12:19 PM #6
-
6 Oct 2008 7:13 PM #7
Updated the demo, so that you can select the type of easing to use, and adjust the duration with the slider.
Took me a few to find all the easing types, but then found a post where Animal said, Use console in firebug, type in Ext.lib.Easing.... Then look at the object. I 'll be damned if I can find that post again. Anyway, just an addition to the silly demo.Thanks!
Chuck
-
7 Oct 2008 12:07 AM #8
Very very nice stuff!
Extensions:
Ext.ux.DatePickerPlus (Multimonth,Multiselect,...)
Ext.ux.menu.StoreMenu - Ajax Store as menu-item config
Extended Window - Aero Shadows, nested grayscaled modal windows
Ext.MessageBox.promptCombo/promptRadio/promptCheckbox
Ext.ux.plugin.triggerfieldTooltip (for Comboboxes, Datefields...)
Ext.util.MD5
Ext.util.Utf8 (encode/decode)
Ext.util.base64 (encode/decode)
Using:
ExtJS 3.4.1.1/4.2
XPsp3/W7sp1
IE8/9/10
FF 20
Chrome 26
-
7 Oct 2008 12:39 AM #9
nice work - what would be pretty neat now is a plugin for it which displays a "paging" toolbar so you can show the user how many cards there are and how far through the sequence they are and allow them to 'jump' to any card in the sequence etc.
-
7 Oct 2008 1:28 AM #10


Reply With Quote