0
我在我的应用中使用了elevatezoom插件。我想要做的只是根据图像盘旋而改变缩放窗口的高度。我可以找到一种方法,但它不能有效地工作。第一次加载页面时不起作用。如果我去另一个页面,看到另一个产品,然后elevatezoom正在工作,因为我想。调整缩放窗口高度提升缩放
这里是我的代码以laravel网址分配:
<div class="product-main-image">
<img src="{{URL::to($product->image)}}" alt="{{$product->title($product->id)}}" class="zoomInner img-responsive" data-zoom-image="{{URL::to($product->image)}}">
</div>
<div class="product-other-images" id="gallery_01">
<a data-update="" data-image="{{URL::to($product->image)}}" data-zoom-image="{{URL::to($product->image)}}">
<img alt="{{$product->title($product->id)}}" src="{{URL::to($product->image)}}"></a>
@if(isset($images) && $images)
@foreach($images as $image)
<a data-update="" data-image="{{URL::to($image->image)}}" data-zoom-image="{{URL::to($image->image)}}">
<img alt="{{$product->title($product->id)}}" src="{{URL::to($image->image)}}"></a>
@endforeach
@endif
</div>
这里是thejavascript它启动变焦和改变zoomwindow高度:
(function() {
$(".product-main-image img").on("load",function() {
var mainImgHeight=$(this).height();
/*var src=$(this).attr("src");
alert(src);*/
$('.zoomInner').elevateZoom({
gallery:'gallery_01',
zoomType: "window",
cursor: "crosshair",
zoomWindowWidth:"400",
zoomWindowHeight:mainImgHeight,
zoomWindowFadeIn: 500,
zoomWindowFadeOut: 750
});
$(".product-main-image img").data("zoom-image","false").elevateZoom();
});
})();
如果我删除最后一行代码片段,缩放工作在第一次加载但是当产品其他图像被点击时,数据缩放图像不会改变。我该如何处理这个问题。我认为当我在load()函数问题中分配一个全局值“mainImgHeight”时可能会得到解决。但一天之后我无法得到它的工作。也许有人有线索。