I’m currently writing a bit on aids again, and I’m currently working on a dynamic resizing function that resizes images to fit in the view-port of the browser. Check for example this image, which should neatly fit the height of your viewport.
To correct for the navbar on top, I need to subtract 120 pixels… Usually, the following bit should do:
var width = (Bheight - 120) * ratio;
where Bheight is the height of total viewport returned by a javascript function. However, that does not work. It yields the wrong aspect ratio.
However, this piece of code worked:
Bheight = Bheight - 120;
var width = Bheight * ratio;
So, I have to do it in two steps. All other languages I’ve touched respects parentheses just fine… I’ve got no clue why JavaScript does not, because it really makes no sense to do that calculation the wrong way what so ever.