Hi,
I have a banner and it works fine except its first loading.
A code is bellow:
[CODE]
var banner = {
acc : null,
tmp_data : null,
type_acc: 0,
curr_acc: 0,
total_acc: 0,
rotator: 8,
firstR: 500,
init : function (){
if (this.type_acc == 1){
banner.getBanner(banner.acc[0]);
banner.curr_acc = banner.curr_acc + 1;
if (banner.curr_acc > banner.total_acc){
banner.curr_acc = 0;
}
$(“#baner”).everyTime(banner.rotator*1000, function(i) {
banner.getBanner(banner.acc[banner.curr_acc]);
banner.curr_acc = banner.curr_acc + 1;
if (banner.curr_acc > banner.total_acc){
banner.curr_acc = 0;
}
});
}
else{
banner.getBanner(banner.acc);
}
},
getBanner : function(data){
banner.tmp_data = data;
$(‘<img title=”‘+banner.tmp_data.title+'” alt=”‘+banner.tmp_data.title+'” src=”‘+banner.tmp_data.img+'” width=”960px” height=”400px” onload=”return ‘+banner.animate_banner()+'”>’);
},
buildDivBanner : function (data){
var div = ‘<a href=”‘+data.url+'” style=”display:none;filter:alpha(opacity=0);-moz-opacity: 0; opacity: 0;”>’;
div += ‘<img title=”‘+data.title+'” alt=”‘+data.title+'” src=”‘+data.img+'” width=”960px” height=”400px”>’;
div += ‘</a>’;
return div;
},
animate_banner: function(){
$(‘#baner a’).animate({
opacity: 0
}, “slow”);
$(‘#baner’).oneTime(500, function(i) {
$(‘#baner a’).css(‘display’, ‘none’);
$(‘#baner’).empty();
banner.firstR = 500;
});
$(‘#baner’).oneTime(this.firstR, function(i) {
$(“#baner”).append(banner.buildDivBanner(banner.tmp_data));
$(‘#baner a’).css(‘display’, ‘block’);
$(‘#baner a’).animate({
opacity: 1
}, “slow”);
});
}
}
How to do loading of the picture smooth when it loads first time?
Now the first loading is not smooth but all the others are smooth.
Thanks!