/    Sign up×
Community /Pin to ProfileBookmark

problems with banner

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”);
});
}
}
[/CODE]

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!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @kromol spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...