Our favorite javascript Slideshow class for MooTools

http://www.efectorelativo.net/laboratory/viewer/

It’s very easy to install and edit. I had syncronize the fading of two elements simultaniously.  All I did was add property to the class like so:

  1.  
  2. var viewer2 = new Class({
  3.  
  4.         mode: ‘rand’,
  5.         modes: [‘top’,‘right’,‘bottom’,‘left’,‘alpha’],
  6.         sizes: {w:480,h:240},
  7.         fxOptions: {duration:3000},
  8.         interval: 5000,
  9.         otherEl: null,
  10.  
  11.         initialize: function(items,options){
  12.                 if(options) for(var o in options) this[o]=options[o];
  13.                 //
  14.                 if(this.buttons){
  15.                         this.buttons.previous.addEvent(‘click’,this.previous.bind(this,[true]));
  16.                         this.buttons.next.addEvent(‘click’,this.next.bind(this,[true]));
  17.                 }
  18.                 this._current = 0;
  19.                 this._previous = null;
  20.                 this.items = items.setStyle(‘display’,‘none’);
  21.                 this.items[this._current].setStyle(‘display’,‘block’);
  22.                 this.disabled = false;
  23.                 this.attrs = {
  24.                         left: [‘left’,-this.sizes.w,0,‘px’],
  25.                         top: [‘top’,-this.sizes.h,0,‘px’],
  26.                         right: [‘left’,this.sizes.w,0,‘px’],
  27.                         bottom: [‘top’,this.sizes.h,0,‘px’],
  28.                         alpha: [‘opacity’,0,1,]
  29.                 };
  30.                 this.rand = this.mode==‘rand’;
  31.                 this.sequence = typeof(this.mode)==‘object’ ? this.mode : false;
  32.                 this.curseq = 0;
  33.                 this.timer = null;
  34.         },
  35.  
  36.         walk: function(n,manual){
  37.                 if(this._current!==n && !this.disabled){
  38.                         this.disabled = true;
  39.                         if(manual){
  40.                                 this.stop();
  41.                         }
  42.                         if(this.rand){
  43.                                 this.mode = this.modes.getRandom();
  44.                         }else if(this.sequence){
  45.                                 this.mode = this.sequence[this.curseq];
  46.                                 this.curseq += this.curseq+1
  47. <this.sequence.length>}
  48.                         this._previous = this._current;
  49.                         this._current = n;
  50.                         var a = this.attrs[this.mode].associate([‘p’,‘f’,‘t’,‘u’]);
  51.                         for(var i=0;i
  52. <this.items.length;i++){>if(this._current===i){
  53.                                         this.items[i].setStyles($extend({‘display’:‘block’,‘z-index’:‘5′},JSON.decode(‘{"’+a.p+‘":"’+a.f+a.u+‘"}’)));
  54.                                 }else if(this._previous===i){
  55.                                         this.items[i].setStyles({‘z-index’:‘4′});
  56.                                 }else{
  57.                                         this.items[i].setStyles({‘display’:‘none’,‘z-index’:‘3′});
  58.                                 }
  59.                         }
  60.                         this.items[n].set(‘tween’,{onComplete:this.onComplete.bind(this),duration:5000}).tween(a.p,a.f,a.t);
  61.                 }
  62.         },
  63.  
  64.         play: function(wait){
  65.                 this.stop();
  66.                 if(!wait){
  67.                         this.next();
  68.                 }
  69.                 this.timer = this.next.periodical(this.interval,this,[false]);
  70.         },
  71.  
  72.         stop: function(){
  73.                 $clear(this.timer);
  74.         },
  75.  
  76.         next: function(manual){
  77.  
  78.                 this.otherEl.walk(this.otherEl._current+1<this.otherEl.items.length ? this.otherEl._current+1 : 0,manual);
  79.                 this.walk(this._current+1<this.items.length ? this._current+1 : 0,manual);
  80.         },
  81.  
  82.         previous: function(manual){
  83.                 this.otherEl.walk(this.otherEl._current>0 ? this.otherEl._current-1 : this.otherEl.items.length-1,manual);
  84.                 this.walk(this._current>0 ? this._current-1 : this.items.length-1,manual);
  85.         },
  86.  
  87.         onComplete: function(){
  88.                 this.disabled = false;
  89.                 this.items[this._previous].setStyle(‘display’,‘none’);
  90.                 if(this.onWalk) this.onWalk(this._current);
  91.         }
  92. });
  93.  </this.items.length;i++){></this.sequence.length>

Implementation looked something like this:

  1.  
  2. if($$(‘.box2 img’).length >0) {
  3.  
  4.                 var V2 = new viewer($$(‘.box2 .Photo’),{
  5.                 mode: ‘alpha’,
  6.                 interval: 1000,
  7.                 duration: 10000
  8.                 });
  9.                 var V3 = new viewer2($$(‘.brownboxtext’),{
  10.                 mode: ‘alpha’,
  11.                 interval: 1000,
  12.                 duration: 10000,
  13.                 otherEl: V2
  14.                 });
  15.                 $$(‘.brownbox’).set(‘opacity’,‘.9′);
  16.  
  17.      }

Pretty easy!

Leave a Reply

watch free movies online download movies online free movies online