1
我發現這個codepen:https://codepen.io/andrearufo/pen/rVWpyE爲什麼這個Bootstrap Carousel刷卡功能不適用於我?
,我很樂意使用它,但由於某種原因,它不會不改變一件事對我的工作,即使我把它複製。爲什麼是這樣?
我沒有忘記嵌入bootstrap或jquery。
我也試過其他解決方案的刷卡功能,但由於某種原因,他們都沒有工作。唯一一個滑動工作的地方(我在谷歌Chrome開發者工具中嘗試過)就在這個codepen上。
$(".carousel").swipe({
swipe: function(event, direction, distance, duration, fingerCount, fingerData) {
if (direction == 'left') $(this).carousel('next');
if (direction == 'right') $(this).carousel('prev');
},
allowPageScroll:"vertical"
});
<div class="container">
<div class="page-header">
<h1>Bootstrap default carousel with swipe and touch gestures</h1>
<p class="lead">How to add the swipes gesture to comand the Bootstrap carousel on mobile devices.</p>
<p>Made by <strong>Andrea Rufo</strong>, more info and tutorial on <a href="http://www.orangedropdesign.com/"> OrangeDropDesign.com</a></p>
</div>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
<li data-target="#carousel-example-generic" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://unsplash.it/1400/600?image=114">
</div>
<div class="item">
<img src="https://unsplash.it/1400/600?image=745">
</div>
<div class="item">
<img src="https://unsplash.it/1400/600?image=315">
</div>
<div class="item">
<img src="https://unsplash.it/1400/600?image=622">
</div>
<div class="item">
<img src="https://unsplash.it/1400/600?image=401">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>