Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace elevatezoom image

Currently I am using elevatezoom for zooming my product pictures. Its a basic zooming functionality. I have a one big image and others are small. I write a code for that. when you click on small image it replace with big image. Its changed correctly but when I was hover on that image zooming functionality not working write my code here can you please help me out.

html code is

<div class="col-xs-12 col-lg-12"> 
    <img id="main_img" class="img-responsive" src="<?=BASE?>/uploaded_content/product/products_speedboot.jpg" data-zoom-image="<?=BASE?>/uploaded_content/product/products_speedboot.jpg"/>
</div>
<div class="col-lg-12 margin-top-10class other-pic-gallary">
    <div class="col-lg-4 padding-remove-left"><img class="img-thumbnail" src="<?=BASE?>/uploaded_content/product/products_speedboot.jpg" /></div>
    <div class="col-lg-4 padding-remove-left"><img class="img-thumbnail" src="<?=BASE?>/uploaded_content/product/Sports_Equipment_Fittings.jpg" /></div>
    <div class="col-lg-4 padding-remove-left"><img class="img-thumbnail" src="<?=BASE?>/uploaded_content/product/products_speedboot.jpg" /></div>
</div>

script code

$(document).ready(function(){
    $('#main_img').elevateZoom({
        zoomType: "inner",
        cursor: "crosshair",
        zoomWindowFadeIn: 500,
        zoomWindowFadeOut: 750
    });

    $('body').on('click','.other-pic-gallary .img-thumbnail',function(){
        //console.log($(this).attr('src'));
        var img_val = $(this).attr('src');
        $('#main_img').attr('src',img_val);
        $('#main_img').attr('data-zoom-image',img_val);
        $('.zoomWindowContainer div').stop().css("background-image","url("+ img_val +")");
        $('#main_img').elevateZoom({
            zoomType: "inner",
            cursor: "crosshair",
            zoomWindowFadeIn: 500,
            zoomWindowFadeOut: 750
        });

    });
});
like image 559
Arya Avatar asked Jun 25 '15 05:06

Arya


1 Answers

I have made a demo for you in FIDDLE

image.on('click', function(){
    // Remove old instance od EZ
    $('.zoomContainer').remove();
    zoomImage.removeData('elevateZoom');
    // Update source for images
    zoomImage.attr('src', $(this).data('image'));
    zoomImage.data('zoom-image', $(this).data('zoom-image'));
    // Reinitialize EZ
    zoomImage.elevateZoom(zoomConfig);
});
like image 125
Vaibs_Cool Avatar answered Oct 08 '22 00:10

Vaibs_Cool