How to use iScroll4 with SwipeView?

前端 未结 2 910
星月不相逢
星月不相逢 2021-01-21 05:23

I\'m using iScroll4 to create a horizontal scroll effect on an image within a mobile website. iScroll works fantastic, but the problem is the image contained in the iScroll wra

2条回答
  •  庸人自扰
    2021-01-21 06:02

    I've found the documentation to be terribly lacking as well but something like this works for me:

    function swipeView(wrapper){
            wrapper = new SwipeView('#wrapper', {
            numberOfPages: pages.length
        });
    
        wrapper.onFlip(function(){
            scroller = new iScroll('.swipeview-active', {
                hScroll: false,
                lockDirection: true
            });
        });
    }
    

    This initialises iScroll on your current SwipeView page upon swiping to it. Horizontal iScroll-scrolling is disabled which leaves that event available to SwipeView and the direction is locked so while a vertical (iScroll) swipe is in progress, a change in the user's swipe-direction won't swipe to the next SwipeView page. Without those options, one can do a bizarre horizontal swipe.

提交回复
热议问题