-
1. Re: image swapping with correct dimensions
AMULI Jun 15, 2013 10:17 AM (in response to AMULI)So, preloading is part of the solution.
An associative array is used to store the twelve full size photos susceptible to be displayed when their thumbnail is hovered over :
var twelvePhotos = new Object();
Inside the loop that fills the row of thumbnails, each corresponding picture is also preloaded and pushed into the associative array :
var photo = new Image();
photo.src = 'images/'+series+index+'.jpg';
twelvePhotos[index] = photo;
Now the width and height are available and always traced by console.log() :
var photo = twelvePhotos[index];
console.log(fileName+' L= '+photo.width+' H= '+photo.height);
The image swap, but width and height still remain the same. I tried in vain :
sym.$('toile').attr({
'width': photo.width,
'height': photo.height,
'src': photo.src
sym.$('toile').attr('width', photo.width);
sym.$('toile').attr('height', photo.height);
sym.$('toile').attr('src', photo.src);
sym.$('toile').attr('width', parseInt(photo.width));
sym.$('toile').attr('height', parseInt(photo.height));
sym.$('toile').attr('src', photo.src);
Clearly, I miss the good syntax. Anyone sees my mistake ?
Gil
-
2. Re: image swapping with correct dimensions
AMULI Jun 17, 2013 4:09 AM (in response to AMULI)The correct syntax is
sym.$('toile').width(photo.width);
sym.$('toile').height(photo.height);
Gil


