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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| var carrousel = {
nbSlide : 0,
i : 0,
elemCurrent : null,
elem : null,
timer: null,
init : function(elem) {
this.elem = elem;
this.nbSlide = elem.find(".slide").length;
elem.find(".slide").hide();
elem.find(".slide").eq(this.i).fadeIn(300);
$("#main-title").show();
$('#prev').css({"opacity" : "0.1"});
$('#next').css({"opacity" : "0.1"});
this.timer = window.setInterval("carrousel.nextSlider()", 500000);
},
nextSlider : function() {
this.elem.find(".slide").eq(this.i).fadeOut(1500);
this.i++;
if (this.i >= this.nbSlide) {
this.i = 0;
}
this.elemCurrent = this.elem.find(".slide").eq(this.i)
this.elemCurrent.fadeIn(1500);
},
prevSlider : function() {
this.elem.find(".slide").eq(this.i).fadeOut(1500);
this.i--;
if (this.i < 0) {
this.i = this.nbSlide - 1;
}
this.elemCurrent = this.elem.find(".slide").eq(this.i)
this.elemCurrent.fadeIn(1500);
},
}
$(function(){
carrousel.init($("#carrousel"));
$('#next').on( 'click', function() {
carrousel.nextSlider();
});
$('#prev').on( 'click', function() {
carrousel.prevSlider();
});
$( "#carrousel" ).mouseenter(function() {
$('#prev').animate({
opacity : "0.9"
}, 200 );
$('#next').animate({
opacity : "0.9"
}, 200 );
});
$( "#carrousel" ).mouseout(function() {
$('#prev').animate({
opacity : "0.1"
}, 200 );
$('#next').animate({
opacity : "0.1"
}, 200 );
});
}); |
Partager