我正在尝试在同一页面上获得多个SWIPERS(idangero.us/swiper/),我正在设置商店,我想为每个类别显示不同的滑动,我很容易生成,这里的问题是第二个闪光灯锁定并且由于某种原因在变换后变焦它会解锁并且我可以滑过它: 有问题的视频:https://streamable.com/s/a88zy/jutbzh
最奇怪的是我尝试复制,但在小提琴中它按预期工作:https://jsfiddle.net/g4b0_88/L9ph48ev/
这里是我为每个类别生成游标的代码:
$scope.loadSwiper = function(idcat){
$scope.swiperSliders[idcat-1] = new Swiper('.swiper'+$scope.store.categories[idcat-1].idcategory, {
direction: 'horizontal',
loop: false,
nextButton: '.button-next'+$scope.store.categories[idcat-1].idcategory,
prevButton: '.button-prev'+$scope.store.categories[idcat-1].idcategory,
slidesPerView: 'auto',
spaceBetween: 0,
freeMode: true
});
$scope.swiperSliders[idcat-1].unlockSwipes();
};
这里是HTML,我在每个类别加载类别和产品:
<div ng-repeat="category in store.categories" ng-repeat-end-watch="categoriesWatcher">
<h1 class="category">{{category.name}}</h1>
<div class="swiper-container swiper{{category.idcategory}}">
<div class="swiper-wrapper featured-carousel">
<div class="swiper-slide product-block" ng-repeat="product in store.featured_products[category.idcategory-1]">
<div id="note{{product.idproduct}}" class="add_product_note note{{product.idproduct}}" ng-show="product_in_cart.data[product.idproduct]"><i class="fa fa-pencil-square-o" ng-click="addProductNote($ev, product.idproduct)" aria-hidden="true"></i></div>
<div class="product-img">
<img class="center-block" ng-src="<?php echo site_url('/assets/product-img/'); ?>{{product.image}}"/>
</div>
<div class="product-name">
<h4>{{product.name}}</h4>
</div>
<div class="product-desc">
<h4>{{product.description}}</h4>
</div>
<div class="product-price">
<p>{{product.sell_price | currency}}</p>
</div>
<div class="product-add" ng-show="product.type == 2">
<ngcart-addtocart id="{{product.idproduct}}" name="{{product.name}}" price="{{product.sell_price}}" quantity="1" img="<?php echo site_url('assets/product-img/');?>{{product.image}}" ptype="{{product.type}}" note="">Agregar</ngcart-addtocart>
</div>
<div class="product-add" ng-show="product.type == 1">
<ngcart-addtocart id="{{product.idproduct}}" name="{{product.name}}" price="{{product.sell_price}}" quantity="0.1" img="<?php echo site_url('assets/product-img/');?>{{product.image}}" ptype="{{product.type}}" note="">Agregar</ngcart-addtocart>
</div>
</div>
</div>
<div class="swiper-button-prev button-prev{{category.idcategory}}"></div>
<div class="swiper-button-next button-next{{category.idcategory}}"></div>
</div>
</div>
正如我所说,Swipers正确加载但由于某种原因而锁定,并在放大或缩小时解锁。
答案 0 :(得分:0)
我找到了解决方案,而不是使用.bak
我放了以下代码块:
$scope.swiperSliders[idcat-1].unlockSwipes();