Hallö,
ich bastel mir gerade nen’ kleinen Image „slider“.
Code dazu:
[CODE]var slider = {
delay: 3000,
imageList: new Array(),
index: -1,
elem: null,
init: function(elem, images) {
this.elem = $(elem);
for(var i = 0; images[i]; i++) {
var img = new Image();
img.src = "../mvc/img/" + images[i];
this.imageList.push(img);
}
if(this.index == -1) {
var img = this.imageList[this.getIndex()];
var elem = this.elem;
elem.html("<img src=\"" + img.src + "\">");
elem.css({height: img.height});
elem.delay(this.delay);
this.next();
}
else
this.next();
},
next: function() {
var img = this.imageList[this.getIndex()];
var elem = this.elem;
elem.animate({opacity: 0, height: img.height}, function() {
elem.html("<img src=\"" + img.src + "\">");
elem.animate({opacity: 1});
elem.delay(this.delay);
this.next();
}, "easeInOutCirc");
},
getIndex: function() {
this.index++;
if(this.index > this.imageList.length)
this.index = 0;
return this.index;
}
};[/CODE]
Rufe ich so auf:
[HTML]
Das erste Bild wird angezeigt, nach 3 Sekunden sollte eig das nächste geladen werden… aber der Callback wird nicht aufgerufen.
Warum?
Ich komm’ nicht drauf.
-Tim