我有一个带有图像幻灯片的示例。在这里,我无法仅借助按钮就可以通过触摸来将图像从一个画面滑动到另一个画面
但是在下面的示例中,我没有做任何不同的事情,只是触摸正常
谁能解释为什么?
示例-CLICK HERE
$(document).ready(function() {
var time = 2;
var $bar,
$slick,
isPause,
tick,
percentTime;
$slick = $('.slider');
$slick.slick({
arrows: true,
speed: 1200,
adaptiveHeight: false
});
$bar = $('.slider-progress .progress');
function startProgressbar() {
resetProgressbar();
percentTime = 0;
isPause = false;
tick = setInterval(interval, 30);
}
function interval() {
if (isPause === false) {
percentTime += 1 / (time + 0.1);
$bar.css({
width: percentTime + "%"
});
if (percentTime >= 100) {
$slick.slick('slickNext');
startProgressbar();
}
}
}
function resetProgressbar() {
$bar.css({
width: 0 + '%'
});
clearTimeout(tick);
}
startProgressbar();
$('.slick-next, .slick-prev').click(function() {
startProgressbar();
});
});
body {
margin: 0;
padding: 0;
}
/* Slider */
.slider-wrapper {
position: relative;
width: 100%;
height: 600px;
overflow: hidden;
}
.slick-slider {
position: relative;
display: block;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-ms-touch-action: none;
touch-action: none;
-webkit-tap-highlight-color: transparent;
}
.slick-list {
position: relative;
overflow: hidden;
display: block;
margin: 0;
padding: 0;
}
.slick-list:focus {
outline: none;
}
.slick-list.dragging {
cursor: pointer;
cursor: hand;
}
.slick-slider .slick-list,
.slick-track,
.slick-slide,
.slick-slide img {
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track {
position: relative;
left: 0;
top: 0;
display: block;
zoom: 1;
}
.slick-track:before,
.slick-track:after {
content: "";
display: table;
}
.slick-track:after {
clear: both;
}
.slick-loading .slick-track {
visibility: hidden;
}
.slick-slide {
float: left;
height: 100%;
min-height: 1px;
display: none;
}
.slick-slide img {
display: block;
max-width: 100%;
}
.slick-slide.dragging img {
pointer-events: none;
}
.slick-initialized .slick-slide {
display: block;
}
.slick-loading .slick-slide {
visibility: hidden;
}
.slick-vertical .slick-slide {
display: block;
height: auto;
border: 1px solid transparent;
}
.slick-slide>.slick-slider-img {
position: relative;
display: block;
width: 100%;
}
.slick-slide .image {
/*height: 180px;*/
}
.slick-slide img {
display: block;
width: 100%;
}
.slick-slide img.slick-loading {
display: none;
}
.slick-prev {
background: #DDD;
border: none;
border-radius: none;
position: absolute;
top: 20%;
transform: translateY(-20%);
left: 0;
padding: 0.25em 0.5em;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
z-index: 400;
}
.slick-next {
background: #DDD;
border: none;
border-radius: none;
position: absolute;
top: 20%;
transform: translateY(-20%);
right: 0;
padding: 0.25em 0.5em;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
z-index: 400;
}
/* progress bar */
.slider-progress {
width: 520px;
height: 10px;
background: rgba(255, 255, 255, 0.5);
/* position: absolute; */
bottom: 0;
border-radius: 16px
}
.slider-progress .progress {
width: 0%;
height: 10px;
background: #e74c3c;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<!-- START SLICK SLIDER -->
<div class="slider-wrapper">
<div class="slider responsive lazy">
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1464082354059-27db6ce50048?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=847&q=80" /></div>
</div>
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1445023835378-9fa9a2089f0c?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=953&q=80" /></div>
</div>
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1441040744088-a70b8213d4d4?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=847&q=80" /></div>
</div>
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1463608666382-cbb244a7bea2?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=1769&q=80" /></div>
</div>
</div>
</div>
<!-- END SLICK SLIDER -->
<div class="slider-progress">
<div class="progress"></div>
</div>