swiper.js和swiper.css资源文件:
链接: https://pan.baidu.com/s/1roJSDBRkq_oL82Q2-d1Xew 提取码: ec5j
使用:
.swiper {
width: 100%;
height: calc(100vh + 100px);
}
.swiper-wrapper {
width: 100%;
min-width: 1420px;
}
.swiper-slide .box {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.swiper-slide .box-left img {
width: 64px;
height: 64px;
}
.swiper-slide .box-right img {
height: 500px;
width: 740px;
}
.swiper-pagination-vertical.swiper-pagination-bullets, .swiper-vertical > .swiper-pagination-bullets {
left: 0;
right: auto;
transform: translateX(200px);
}
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="box">
div>
div>
<div class="swiper-slide">
<div class="box">
div>
div>
<div class="swiper-slide">
<div class="box">
div>
div>
<div class="swiper-slide">
<div class="box">
div>
div>
div>
<div class="swiper-pagination">div>
div>
// js 动画
var mySwiper = $('.mySwiper');
var swiper = new Swiper(".mySwiper", {
direction: "vertical",
slidesPerView: 1,
spaceBetween: 30,
mousewheel: true,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
on: {
slidePrevTransitionEnd: function () {
var index = swiper.activeIndex;
index === 0 ? mySwiper.css('pointer-events', 'none') : mySwiper.css('pointer-events', 'auto');
},
slideNextTransitionEnd: function () {
swiper.isEnd ? mySwiper.css('pointer-events', 'none') : mySwiper.css('pointer-events', 'auto');
},
}
});
window.onmousewheel = tran;
function tran(ev) {
var ev = ev || window.event;
var top = document.documentElement.scrollTop;
var index = swiper.activeIndex;
if (ev.wheelDelta < 0) {
if (top > 940) {
unScroll();
$('.header').css({'position': 'fixed', 'z-index': '9'});
}
if(index === 3){
removeUnScroll();
}
console.log('向下滚动', document.documentElement.scrollTop)
} else {
if (top < 980) {
unScroll();
mySwiper.css('pointer-events', 'auto');
}
if(index === 0){
removeUnScroll();
$('.header').css({'position': 'relative'});
}
console.log('向上滚动', document.documentElement.scrollTop)
}
}
function unScroll() {
var top = $(document).scrollTop();
$(document).on('scroll.unable',function (e) {
$(document).scrollTop(top);
})
}
function removeUnScroll() {
$(document).unbind("scroll.unable");
}