slide without translate problem
by __R2D2
HTML
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<div class="swiper-pagination"></div>
<div class="swiper-container my-swiper">
<section class="swiper-wrapper">
<p class="swiper-slide">ここには<br>いろんな<br>長さの<br>文章が入ります。</p>
<p class="swiper-slide">ここには<br>文章が入ります。</p>
<p class="swiper-slide">ここには<br>文章が入ります。</p>
<p class="swiper-slide">ここには文章が入ります。</p>
</section>
</div>
SCSS
html {
font-size: 62.5%;
height: 100%;
}
.my-swiper {
margin: 2.8rem 0 0 0;
height: 37.8rem;
overflow-y: scroll;
overflow-x: hidden;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
}
.swiper-wrapper {
p {
opacity: 0.3;
margin-bottom: 2.7rem;
height: auto;
}
.swiper-slide-active {
opacity: 1;
}
}
JavaScript
var mySwiper = new Swiper('.my-swiper', {
on: {
init: function() {
this.snapGrid = this.slidesGrid;
},
slideChange: function() {
document.querySelector('my-swiper').style.transform = "translate3d(0,0,0)";
}
},
direction: 'vertical',
autoHeight: true,
slideToClickedSlide: true,
slidesPerView: 'auto',
passiveListeners: false,
keyboard: {
enabled: true,
},
mousewheel: {
forceToAxis: true,
},
pagination: {
el: '.swiper-pagination',
type: 'bullets',
clickable: 'true',
},
renderBullet: function(index, className) {
return '<span class="' + className + '">' + (index + 1) + '</span>';
},
});