Wrogn image width
Wrogn image width
Hello! I have a problem. When I start this script first time (before I clear history and cache page) one or two or some miniatures have to much width (generic function create img). When I refresh the page this miniatures width are ok.. When I add some alert in the generic function and start this script first time miniatures width are ok too. Where is a problem? Sorry :) my English is so bad.
-
function galeria(wys_f,wys_s,full_Out,full_In,fade_To,opacity,opacity2,opis_div,full_div,menu_div) {
var index = 0;
var stan = 0;
var szer_full;
var wys_full;
var szer_small;
var w_img_f;
var s_img_f;
var s_img;
var ratio;
var ilosc = $(full_div+' img').length;
function show_full() {
w_img_f = $(full_div+' img').eq(index).height();
s_img_f = $(full_div+' img').eq(index).width();
s_img = (s_img_f)/(w_img_f/wys_f);
$(full_div+' img').eq(index).attr("width", s_img);
$(full_div+' img').eq(index).attr("height", wys_f);
$(full_div+' img').fadeOut(full_Out);
$(full_div+' img').eq(index).fadeIn(full_In);
};
function generic() {
for ( var x=0;x<=(ilosc-1);x++ ) {
var new_src = $(full_div+' img').eq(x).attr("src");
szer_full = $(full_div+' img').eq(x).width();
wys_full = $(full_div+' img').eq(x).height();
ratio = szer_full / wys_full;
szer_small = wys_s * ratio;
var new_img = new Image(szer_small,wys_s);
new_img.src = new_src;
var new_link = $("<a></a>");
new_link.attr("href", "#");
$(menu_div).append(new_link);
new_link.append(new_img);
new_link.fadeTo(0, opacity);
$(menu_div+' a').eq(index).fadeTo(0, 1);
new_link.click(function() {
index = $(menu_div+' a').index(this);
if ( stan != index ) {
$(menu_div+' a').not(this).fadeTo(fade_To, opacity);
$(menu_div+' a').eq(index).fadeTo(0, 1);
show_full();
show_title();
stan = index;
return false;
};});
new_link.hover(function() { if ( $(menu_div+' a').index(this) == stan ) { return false; } else { $(this).fadeTo(fade_To, opacity2); };},function() { if ( $(menu_div+' a').index(this) == stan ) { return false; } else { $(this).fadeTo(fade_To, opacity); };});
};
};
function show_title() {
$(opis_div+' p').remove();
$(opis_div+' h3').remove();
var new_title = $("<h3></h3>");
var new_opis = $("<p></p>");
var title = $(full_div+' img').eq(index).attr("title");
var opis = $(full_div+' img').eq(index).attr("alt");
new_title.html(title);
new_opis.html(opis);
$(opis_div).append(new_title);
$(opis_div).append(new_opis);
};
show_title();
show_full();
generic();
}