0
javascriptの特定のswiperエレメントでselect/touch-eventをキャッチするにはどうすればよいですか?javascript swiper特定のスワイパーエレメント
アイデアは、画像のセットをブラウズして特定の選択を行うために、ユーザーにスワイパー機能を使用させることです。この選択は、コードの他の場所で使用されます。
以下のコードの例では、例を挙げてイベントをキャッチしたいと思います。 「スライド9」が押された。
これは、何らかの理由で、スライドのタッチとプレス/リリースイベントのタッチを区別する方法を意味しています。クリックされたスライドのインデックス番号を取得するには、スライダのクリック操作で 感謝
<head>
<meta name = "viewport" content = "width = device-width, initial-scale = 1,
maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />
<meta name = "apple-mobile-web-app-capable" content = "yes" />
<meta name = "apple-mobile-web-app-status-bar-style" content = "black" />
<title>Multiple Swipers</title>
<link rel = "stylesheet"
href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />
<link rel = "stylesheet"
href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />
</head>
<body>
<div class = "views">
<div class = "view view-main">
<div class = "pages">
<div data-page = "home" class = "page navbar-fixed">
<div class = "navbar">
<div class = "navbar-inner">
<div class = "left"> </div>
<div class = "center">Multiple Swipers</div>
<div class = "right"> </div>
</div>
</div>
<div class = "page-content">
<div class = "content-block-title">4 Slides Per View, 10px Between</div>
<div class = "swiper-container swiper-4">
<div class = "swiper-pagination"></div>
<div class = "swiper-wrapper">
<div class = "swiper-slide"><span>Slide 1</span></div>
<div class = "swiper-slide"><span>Slide 2</span></div>
<div class = "swiper-slide"><span>Slide 3</span></div>
<div class = "swiper-slide"><span>Slide 4</span></div>
<div class = "swiper-slide"><span>Slide 5</span></div>
<div class = "swiper-slide"><span>Slide 6</span></div>
<div class = "swiper-slide"><span>Slide 7</span></div>
<div class = "swiper-slide"><span>Slide 8</span></div>
<div class = "swiper-slide"><span>Slide 9</span></div>
<div class = "swiper-slide"><span>Slide 10</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type = "text/javascript"
src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
<style>
.swiper-slide {
background:#fff;
box-sizing:border-box;
border:1px solid #ccc;
line-height:120px;
text-align:center;
}
.swiper-slide span {
font-size:17px;
}
.swiper-container {
height:120px;
margin:0px 0 35px;
}
</style>
<script>
var myApp = new Framework7();
// 4 Slides Per View, 10px Between
var mySwiper4 = myApp.swiper('.swiper-4', {
pagination:'.swiper-4 .swiper-pagination',
spaceBetween: 10,
slidesPerView: 4,
});
</script>
</body>
</html>