如何使旋转木马与左侧的滑动重叠。我不想使用插件外部网站,我想查看代码示例或编写主题轮播的方法编程 示例:
参考:https://codepen.io/desandro/pen/myXdej 未显示示例代码编程
<script>
$(".carousel").swipe({
swipe: function(event, direction, distance, duration, fingerCount, fingerData) {
if (direction == 'left') $(this).carousel('next');
if (direction == 'right') $(this).carousel('prev');
},
allowPageScroll:"vertical"
});
</script>
<script>
$(function () {
var position = 0;
$('#next').on('click', function (e) {
e.preventDefault();
position = (position + 25) % 110;
$('.carousel .item').css('-webkit-transform', 'translateX(-' + position + '%)');
});
});
</script>
<div class="container">
<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=62">
</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>