My goal is to scale an image with the ID "room" by a parameter of +1 or -1, which represents +-10% of the constant scaling factor.
This is my current approach:
function scalar(scaleP100){ /* scaleP100 ranges from +1 to -1 */
var addX = $('#room').width()*10*scaleP100/100;
var addY = $('#room').height()*10*scaleP100/100;
var newW = $('#room').width() + addX;
var newH = $('#room').height() + addY;
$('img#room').css({'width':newW,'height':newH});
console.log(newW +','+ newH+':'+$('img#room').length);
return false;
}
This function is triggered by mousewheel detection and has two stages: +10% increase from the original size and -10% decrease from the original size. However, I am facing an issue where it scales according to the original size instead of the current size.
I am unsure about what mistake I am making in my code. Any suggestions?
To further illustrate any points that may not have been explained clearly, feel free to visit (scroll outside the image only).
Thank you!