Код
'crossfade':function(img) {
this.title.innerHTML=img.dataset.title;
this.image2.style.opacity=1;
this.image.style.opacity=0;
this.image.src = img.src;
this.interval=window.setInterval((function(){
var opacity = this.image.style.opacity*100;
opacity+=20;
if(opacity >= 100) {
window.clearInterval(this.interval);
this.interval=null;
this.image.style.opacity=1;
this.image2.style.opacity=0;
}
else {
this.image.style.opacity=opacity/100;
this.image2.style.opacity=1-(opacity/100);
}
}).bind(this),10);
}