我发现这个特效有点问题,初始化时,向下稍微拉一下,就会出现“正在加载”,源码中滑动的距离是要大于50px才会触发,我这里是这样解决的:
加一个差值_diff
var _diff = _viewHeight - _contentHeight; if (this.translate <= (_diff >= 0 ? -50 : _viewHeight - _contentHeight - 50) && this.translate < 0) { //触发 }
var mySwiper = new Swiper('.swiper-container', { direction: 'vertical', scrollbar: '.swiper-scrollbar', slidesPerView: 'auto', mousewheelControl: true, pagination: '.swiper-pagination', observer: true, observeParents: true, freeMode: true,
加上
pagination: '.swiper-pagination', observer: true, observeParents: true,
这三行
有个问题:当一个页面里面上拉加载次数多了以后,再左右滑动至其他swiper-slide ,其他swiper-slide 也会触发这个上拉加载事情,