-
1. Re: how to get the width and height of a loaded image ?
resdesign Sep 11, 2013 3:06 PM (in response to AMULI)Have you tried:
var rect = sym.$('Rectangle');
alert(rect.height());
same with width()
with width() and height() you get an integer.
-
2. Re: how to get the width and height of a loaded image ?
Zaxist Sep 11, 2013 5:21 PM (in response to AMULI)Dear Gil
you are doing it in wrong way, you dont need all of this mess !!
See my Sample : http://www.mediafire.com/download/ptp9xn3rus2y6em/Dynamic_Slide_Show_JSON.rar
Zaxist
-
3. Re: how to get the width and height of a loaded image ?
AMULI Sep 13, 2013 2:59 AM (in response to Zaxist)Much better demesstified Thanks, Zaxist.
brands = {};
byLetter = {'A':0,'B':0,'C':0,'D':0,'E':0,'F':0,'G':0,'H':0,'I':0,'J':0,'K':0,'L':0,'M':0,
'N':0,'O':0,'P':0,'Q':0,'R':0,'S':0,'T':0,'U':0,'V':0,'W':0,'X':0,'Y':0,'Z':0};
//------------------------------------------------------
$.getJSON( 'brands.json', function(data)
{
// the JSON file contains objects sorted by alphabetical order of their brand property
brands = data;
// initialize the array of entries by letter
var key = 'z';
$.each( data, function( index, entry)
{
var initial = entry.brand.charAt(0);
if (initial != key && initial !='É')
{
byLetter[ initial] = index;
key = initial;
}
});
// fill empty entries
for (var keyLetter in byLetter)
{
if (byLetter[ keyLetter] == 0 && keyLetter != 'A')
{
if (keyLetter == 'Z')
{
byLetter[ 'Z'] = byLetter[ 'Y'];
} else {
// next entry value
byLetter[ keyLetter] = byLetter[ String.fromCharCode( keyLetter.charCodeAt() +1)];
}
}
}
swapLogos( 0);
});
//------------------------------------------------------
function swapLogos( iFirst)
{
console.log( iFirst);
for( var i = 0; i < 15; ++i)
{
var theLogo = sym.getSymbol( "cell_" +(i +1)).$('square');
var iBrand = iFirst +i;
if (iBrand < brands.length)
{
theLogo
.css(
{
"background-image":"url(images/" +brands[ iBrand].logo +".gif)",
"background-size":"auto",
"background-repeat":"no-repeat",
"background-position":"center"
})
.show();
} else {
theLogo.hide();
}
}
}
//------------------------------------------------------
$('.lettre').on('click', function()
{
var letter = $( this).attr( 'ID').charAt( 6); // Stage_A
swapLogos( byLetter[ letter]);
// update highlighted letter (color)
$('.lettre').css( 'color', '#EEE');
$(this).css( 'color', '#FF3');
});
//------------------------------------------------------
Dowloadable here : https://app.box.com/s/c1hlvbfrum4yzypc1mid
Gil
-
4. Re: how to get the width and height of a loaded image ?
Zaxist Sep 14, 2013 5:30 AM (in response to AMULI)Great job Dear Gil
Now it looks Professional
Zaxist




