自适应页面 + 翻页锁的 swiper!Self-adaption pages + slide lock Swiper for h5
npm install wgswiperautoHeight doesn't help.
direction is 'vertical' too, set its nested to true.
body { width: 100%; height: 100%; overflow: hidden;}
+ Set followFinger false and set virtualTranslate true to cancel swiper's translate and touchevent.
+ Init slide's height with .swiper-height's clientheight when page loaded.
+ When onSlide, adjust wrapper css accroding to slide's height to slide.
+ When in those long page, cancel swiper's touchevent and scroll. Add event handler to deal with scroll in the page. declare a lock to protect from sliding when first hit the page edge. Springback will affect if there's next page.
+ If used window.onload. Do as addOnloadListener().
+ getSwiper() return swiper object. How to use it? Refer to official api doc
useage
install
npm i -S wgswiper
`
`
`
new Wgswiper();
new Wgswiper(()=>{
// do whatever you want when the swiper init
// this is THE ONLY WAY you can add init handler
// for more, https://swiperjs.com/api/#events
}));
let wgswiper = new Wgswiper().getSwiper();
// add other event handles
// init NOT allowed here
// for more, https://swiperjs.com/api/#events
wgswiper.on('slideChange',()=>{
// do whatever you want
})
``