/* * jquery javascript plugin jquery.zoomimgrollover 0.9.0 * http://bugsoftware.co.uk/jquery/ * * copyright (c) 2010 ritchie comley * dual licensed under the mit and gpl licenses. * * date: 2010-01-19 (thu, 19 january 2010) * revision: 29 * * dependencies: * jquery 1.4 (jquery.com) * */ (function(jquery){ jquery.fn.zoomimgrollover = function(options) { var defaults = { percent:30, duration:600 }; var opts = jquery.extend(defaults, options); // static zoom function function imagezoomstep(jzoomimage, x, origwidth, origheight) { var width = math.round(origwidth * (.5 + ((x * opts.percent) / 200))) * 2; var height = math.round(origheight * (.5 + ((x * opts.percent) / 200))) * 2; var left = (width - origwidth) / 2; var top = (height - origheight) / 2; jzoomimage.css({width:width, height:height, top:-top, left:-left}); } return this.each(function() { var jzoomimage = jquery(this); var origwidth = jzoomimage.width(); var origheight = jzoomimage.height(); // add css ness. to allow zoom jzoomimage.css({position: "relative"}); jzoomimage.parent().css({overflow: "hidden", display:"block", position: "relative", width: origwidth, height: origheight}); jzoomimage.mouseover(function() { jzoomimage.stop().animate({dummy:1},{duration:opts.duration, step:function(x) { imagezoomstep(jzoomimage, x, origwidth, origheight) }}); }); jzoomimage.mouseout(function() { jzoomimage.stop().animate({dummy:0},{duration:opts.duration, step:function(x) { imagezoomstep(jzoomimage, x, origwidth, origheight) }}); }); }); }; })(jquery);