Looking to achieve animation of an image and maintain it centered in the active window. I have attempted the code below, but it's not functioning properly. Any suggestions on how I can enhance the code for successful execution?
// determine image dimensions
var h = $(this).height();
var w = $(this).width();
// retrieve div dimensions
var div_h =$('#imgContainer').height();
var div_w =$('#imgContainer').width();
var pY = Math.round((div_h - h) / 2) + 'px';
var pX = Math.round((div_w - w) / 2) + 'px';
$(this).animate({
opacity:"1",
top: pY+"px",
left: pX+"px",
zoom: '500%'
}, 'medium')