jackmoore / zoom

jQuery plugin for zooming images on mouseover.
http://www.jacklmoore.com/zoom/
MIT License
1.54k stars 460 forks source link

Add minimal zoom ratio #80

Open ppowalowski opened 9 years ago

ppowalowski commented 9 years ago

There should be something like a minimal zoomratio so the user can decide when it's worthy for jquery-zoom to kick in magnification. Currently it also applies magnification if the target image is smaller - this should be at least locked to 1:1 ratio.

jordanranson commented 8 years ago

I agree. Our image container is a fixed height and sometimes the content image is smaller than the container so it gets stretched, making the "zoom" actually zoom out.

jquery zoom

BehrouzSohrabi commented 7 years ago

modify this block of code and it will be fixed.

move: function(e) {
    var left = (e.pageX - offset.left),
        top = (e.pageY - offset.top);
    if (xRatio < 0) {
        xRatio = 0
        img.style.width = sourceWidth + 'px';
    }
    if (yRatio < 0) {
        yRatio = 0
        img.style.height = sourceHeight + 'px';
    }
    top = Math.max(Math.min(top, sourceHeight), 0);
    left = Math.max(Math.min(left, sourceWidth), 0);
    img.style.left = (left * -xRatio) + 'px';
    img.style.top = (top * -yRatio) + 'px';
}