1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
$(document).ready(function(){
s = new slidermade("#gal");
});
var slidermade = function(id){
var self=this;
this.div = $(id);
this.slidermade=this.div.find(".gallery_demo");
this.largeurCache = this.div.width();
this.largeur=450;
this.suiv = this.div.find(".suivslid");
this.prec = this.div.find(".precslid");
this.saut = this.largeurCache/5;
this.nbEtapes = Math.ceil(this.largeur/this.saut);
this.courant=0;
this.suiv.mouseover(function(){
if(self.courant<=self.nbEtapes){
self.courant++;
self.slidermade.animate({
left:-self.courant*self.saut
},1100);
}
});
this.suiv.click(function(){
if(self.courant<=self.nbEtapes){
self.courant++;
self.slidermade.animate({
left:-self.courant*self.saut
},1000);
}
});
this.prec.mouseover(function(){
if(self.courant>0){
self.courant--;
self.slidermade.animate({
left:-self.courant*self.saut
},1100);
}
});
this.prec.click(function(){
if(self.courant>0){
self.courant--;
self.slidermade.animate({
left:-self.courant*self.saut
},1000);
}
});
} |
Partager