seo-optimize-iframe/pages/swiper/swiper.html

92 lines
3.3 KiB
HTML
Raw Normal View History

2022-04-14 10:02:22 +00:00
<html lang="en">
<head>
<meta charset="utf-8">
<title>swiper卡片叠加点击切换代码演示_大头网</title>
<link rel="stylesheet" href="../../css/swiper.min.css">
<link rel="stylesheet" href="../../css/datouwang.com.css">
<script></script>
</head>
<body>
<div id="persons">
<div class="swiper-container swiper-container-initialized swiper-container-horizontal">
<div class="swiper-wrapper">
<div class="swiper-slide swiper-slide-duplicate" data-swiper-slide-index="0">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate" data-swiper-slide-index="1">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate swiper-slide-duplicate-prev"
data-swiper-slide-index="2">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate swiper-slide-duplicate-active"
data-swiper-slide-index="3">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate-next" data-swiper-slide-index="0">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
<div class="swiper-slide swiper-slide-duplicate-next" data-swiper-slide-index="0">
<img src="../../imgs/public/小桶龙.png" alt="">
</div>
</div>
<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>
</div>
<div class="swiper-pagination swiper-pagination-bullets"><span class="swiper-pagination-bullet"></span><span
class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span><span
class="swiper-pagination-bullet swiper-pagination-bullet-active"></span></div>
<div class="swiper-button-prev" tabindex="0" role="button" aria-label="Previous slide"></div>
<div class="swiper-button-next" tabindex="0" role="button" aria-label="Next slide"></div>
</div>
<script src="../../js/swiper.min.js"></script>
<script>
var personsSwiper = new Swiper('#persons .swiper-container', {
watchSlidesProgress: true,
slidesPerView: 'auto',
centeredSlides: true,
loop: true,
autoplay: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-pagination',
},
on: {
progress: function(progress) {
for (i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i);
var slideProgress = this.slides[i].progress;
modify = 1;
if (Math.abs(slideProgress) > 1) {
modify = (Math.abs(slideProgress) - 1) * 0.3 + 1;
}
translate = slideProgress * modify * 260 + 'px';
scale = 1 - Math.abs(slideProgress) / 5;
zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
slide.transform('translateX(' + translate + ') scale(' + scale + ')');
slide.css('zIndex', zIndex);
slide.css('opacity', 1);
if (Math.abs(slideProgress) > 3) {
slide.css('opacity', 0);
}
}
},
setTransition: function(transition) {
for (var i = 0; i < this.slides.length; i++) {
var slide = this.slides.eq(i)
slide.transition(transition);
}
}
}
})
</script>
</body>
</html>