jackmoore / zoom

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

('.several_images').zoom() is being wierdly sticky on the first image #103

Open morgunder opened 8 years ago

morgunder commented 8 years ago

my use case is to apply zoom to a bunch of thumbnails all at once. and when i do that as in the title, the 2nd + images work perfectly in that as i mouse in and out the image zooms in. however the first image is shoved to absolute position 0,0 and stuck showing the big image.

can you make it so in this case it requires a mouse over to trigger the zoom?

jjui commented 8 years ago

Thinking if you applied .zoom() in a each function will be best, like:

    $('.several_images').each(function(){       
        var src = $(this).find('img').attr('src');
        $(this).zoom({
            url: src,
            touch: false,
            on: 'click',
            duration: 50,
            magnify: 0.75
        });
    });

And to make the whole thing smooth, apply css translate3d() to achieve hardware acceleration like (sass):

.zoom img {
    @include transition(all 0.5s ease-out);
    @include transform(translate3d(0,0,0));
}

Will make a PR for auto hardware acceleration.

Best, /J