I would like to set the magnification after the callback, so I can set it based on the ratios of original image sizes to my viewport. Some of the images may be smaller than the viewport, so I need to magnify those.
How can I write this?
The trouble is with the last line (magnify:magnification). It's undefined and I don't know the syntax for setting the options after the callback. If you can.
$('#parent').zoom({
url: path,
duration: 120,
callback: function(){
var w = $(this).width();
var h = $(this).height();
var pw = $('#parent').width();
var ph = $('#parent').height();
if ( w<pw ) {
var magnification = Math.ceil( (pw/w).toFixed(2) ) + .2;
} else if ( h<ph ) {
var magnification = Math.ceil( (ph/h).toFixed(2) ) + .2;
} else {
var magnification = 2;
}
},
magnify: magnification
});
I would like to set the magnification after the callback, so I can set it based on the ratios of original image sizes to my viewport. Some of the images may be smaller than the viewport, so I need to magnify those.
How can I write this? The trouble is with the last line (magnify:magnification). It's undefined and I don't know the syntax for setting the options after the callback. If you can.
Thanks!