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
});
});
});
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);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With