-
21 May 2008 12:40 PM #1
[2.x] Ext.ux.ImageSlideshow
[2.x] Ext.ux.ImageSlideshow
Hi,
I was writing a image slideshow extension for one of my projects.
and implementation:Code:Ext.ux.ImageSlideshow = Ext.extend(Ext.Container, { start: 0, duration: 1, easing: 'easeNone', pause: 5000, // private initComponent : function(){ Ext.ux.ImageSlideshow.superclass.initComponent.call(this); this.tpl = new Ext.Template('<img src="{url}">'); this.tpl.compile(); if(this.ds) { this.store = this.ds; delete this.ds; } else { this.store = new Ext.data.JsonStore({ autoLoad: this.autoLoad, baseParams: this.params, url: this.url, root: 'data', fields: [ {name: 'url', type: 'string'} ] }); } this.store = Ext.StoreMgr.lookup(this.store); this.store.on('load', this.loop, this); }, // private onRender: function(ct, position) { this.el = ct.createChild({ id: this.id, cls: this.baseCls }, position); this.el.setWidth(this.width); this.el.setHeight(this.height); }, load: function() { this.store.load(); }, //private loop: function() { if(this.store.getCount()>0) { var r = this.store.getAt(this.start++); this.el.fadeOut({ duration: this.duration, easing: this.easing, scope: this, useDisplay: true, callback: function() { this.tpl.overwrite(this.el.dom, r.data); this.el.fadeIn({ duration: this.duration, easing: this.easing, scope: this, callback: function() { if( this.start == this.store.getCount() ) { this.start = 0; } setTimeout( this.loop.createDelegate(this), this.pause ); } }); } }); } } }); Ext.reg('image-slideshow', Ext.ux.ImageSlideshow);
and data:Code:var slideshow = new Ext.ux.ImageSlideshow({ autoLoad: true, renderTo: 'commercial', width: 1000, height: 225, url: basePath+'/action/image/getImageSlideshow', params: {tournamentId: tournamentId, type: 'COMMERCIAL_1000x225'} });
ThanksCode:{ "success" : true, "totals" : 3, "data" :[{ "height" : 225, "url" : "/action/image/get?id=10048", "width" : 1000 },{ "height" : 225, "url" : "/action/image/get?id=10049", "width" : 1000 },{ "height" : 225, "url" : "/action/image/get?id=10047", "width" : 1000 }] }Last edited by gizzmo; 17 Jul 2008 at 11:00 AM. Reason: Updated code
MobilEpost - http://www.mobilepost.se
ResultReporter - http://www.resultreporter.com
Butiksbelysning - http://www.butiksbelysning.se
sverin.net http://www.sverin.net
-
23 May 2008 4:14 AM #2
The slideshow works fine in FF, but not in IE6 or IE7. Can anyone confirm?
MobilEpost - http://www.mobilepost.se
ResultReporter - http://www.resultreporter.com
Butiksbelysning - http://www.butiksbelysning.se
sverin.net http://www.sverin.net
-
24 May 2008 4:03 PM #3
-
2 Jul 2008 7:28 PM #4
Hello gizzmo,
Found your extension useful. Did you ever find the solution to your fading issue? I was able to run in IE and FF with no problem by adding "useDisplay: true" to your fadeOut config:
The issue is with IE and visibility mode. See this post for info:Code:... this.el.fadeOut({ duration: this.duration, easing: this.easing, useDisplay: true, scope: this, callback: function() { ...
http://extjs.com/forum/showthread.php?p=84257#post84257
-
15 Jul 2008 6:54 PM #5
I understood till the implementation but could you explain how you are giving it the data please? Are the brackets supposed to be there like that?
-
16 Jul 2008 1:21 PM #6
The data are created from a regular ajax POST/GET from the url and returned as json data from the server side. The data are then stored in an JsonStore as seen from the code.
[CONFIRMED] I'll try this as soon as possible. Thanks gugman...I was able to run in IE and FF with no problem by adding "useDisplay: true" to your fadeOut config:
What brackets do you meen?Are the brackets supposed to be there like that?Last edited by gizzmo; 16 Jul 2008 at 1:48 PM. Reason: Confirmed gugmans suggestion. Updated code...
MobilEpost - http://www.mobilepost.se
ResultReporter - http://www.resultreporter.com
Butiksbelysning - http://www.butiksbelysning.se
sverin.net http://www.sverin.net
-
16 Jul 2008 3:58 PM #7
Oh so it takes the input from basePath+'/action/image/getImageSlideshow' is it? Sorry about that... I'm a little new to ExtJS so its taking me some time to get used to all the syntaxes...
Just as a matter of curiosity... is there a way to give a list of images using the declaration itself without doing call to a remote script?
-
17 Jul 2008 10:54 AM #8
The code has been updated to take any store if provided...
So, this is an example of creating it without a server call.Code:Ext.ux.ImageSlideshow = Ext.extend(Ext.Container, { start: 0, duration: 1, easing: 'easeNone', pause: 5000, // private initComponent : function(){ Ext.ux.ImageSlideshow.superclass.initComponent.call(this); this.tpl = new Ext.Template('<img src="{url}">'); this.tpl.compile(); if(this.ds) { this.store = this.ds; delete this.ds; } else { this.store = new Ext.data.JsonStore({ autoLoad: this.autoLoad, baseParams: this.params, url: this.url, root: 'data', fields: [ {name: 'url', type: 'string'} ] }); } this.store = Ext.StoreMgr.lookup(this.store); this.store.on('load', this.loop, this); }, // private onRender: function(ct, position) { this.el = ct.createChild({ id: this.id, cls: this.baseCls }, position); this.el.setWidth(this.width); this.el.setHeight(this.height); }, load: function() { this.store.load(); }, //private loop: function() { if(this.store.getCount()>0) { var r = this.store.getAt(this.start++); this.el.fadeOut({ duration: this.duration, easing: this.easing, scope: this, useDisplay: true, callback: function() { this.tpl.overwrite(this.el.dom, r.data); this.el.fadeIn({ duration: this.duration, easing: this.easing, scope: this, callback: function() { if( this.start == this.store.getCount() ) { this.start = 0; } setTimeout( this.loop.createDelegate(this), this.pause ); } }); } }); } } }); Ext.reg('image-slideshow', Ext.ux.ImageSlideshow);
I'll post the latest code in the beginning...Code:var store = new Ext.data.SimpleStore({ fields: [ {name: 'url'} ] }); var myData = [ ['images/babolat.jpg'], ['images/dunloop.jpg'] ]; var panel = new Ext.Panel({ renderTo: 'container', title: 'Image Slideshow', style: 'padding: 10px', frame: true, width: 213, items: { xtype: 'image-slideshow', ds: store, width: 180, height: 300 } }); store.loadData(myData);MobilEpost - http://www.mobilepost.se
ResultReporter - http://www.resultreporter.com
Butiksbelysning - http://www.butiksbelysning.se
sverin.net http://www.sverin.net
-
29 Nov 2011 2:15 AM #9
Ext.ux.ImagesSlideshow for looping (after last image back to first imagea gain)
Ext.ux.ImagesSlideshow for looping (after last image back to first imagea gain)
I try this code, but doesn't to loop(back to first image after last image). Any suggestion?


Reply With Quote
