Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: 页面无法正常滚动 #375

Open
qpxtWhite opened this issue May 27, 2016 · 5 comments
Open

Bug: 页面无法正常滚动 #375

qpxtWhite opened this issue May 27, 2016 · 5 comments

Comments

@qpxtWhite
Copy link

touchmove的时候,阻止了默认事件
当手指按在元素上时,无法正常滚动页面

@zhoukekestar
Copy link

zhoukekestar commented Jun 1, 2016

设置fixPage属性为false貌似可以

var slider = new iSlider(ele, list, {
        isAutoplay: 1,
        isLooping: 1,
        isOverspread: 1,
        animateTime: 800,
        plugins: [ ['dot', { locate: 'relative' }] ],
        fixPage: false
        //animateType: 'flow'
});

默认行为的取消主要在这行代码:
https://github.com/be-fe/iSlider/blob/master/src/js/iSlider.js#L1155
这个属性的解释
http://be-fe.github.io/iSlider/demo/#fixpage
在我们的项目中是可以了
https://m.toomao.com/square
a

@qpxtWhite
Copy link
Author

我试了下,把fixPage设为false的确可以了;

还有点小瑕疵:
焦点图高度比较高,上下拖动页面时有左右位移,会导致焦点图进行切换
我暂时的做法是,在源码touchmove时,做了判断

            if(judgeflag === 0 && !self.isVertical){    //判断
                var judgeOffsetX = evt.targetTouches[0].clientX - judgeStartX;
                var judgeOffsetY = evt.targetTouches[0].clientY - judgeStartY;
                var ratio = Math.abs(judgeOffsetX) - Math.abs(judgeOffsetY);
                if(ratio > 10){
                    judgeflag = 1;  //左右切换焦点图
                } else if(ratio < -10){
                    judgeflag = -1; //上下拖动页面
                } else {
                    judgeflag = 0;
                }
                return;
            }
            if(judgeflag === -1){   //滚动页面,直接返回,不做slide处理
                return;
            }

不知道这样子有没有什么问题

@shinate
Copy link
Member

shinate commented Jun 13, 2016

这里没有特别进行处置,其实这个功能考虑过,但是会出现要求纵向切换并且纵向滚动的场景,╮(╯▽╰)╭ 无解的,所以留给fixPage===false时,自行添加判断吧

@Sssnone
Copy link

Sssnone commented Apr 17, 2017

当使用animateType: 'flow'的时候,没法定义一个可以scroll的content啊。不然根本无法滚动,若设置fixPage==false的话,flow的动画就没了啊,求助

@shinate
Copy link
Member

shinate commented Apr 18, 2017

上面有表示过,touch的触发动作可以自行解决的,框架能做的只有“不阻止默认事件”而已。况且,根据一般的经验,滑动和内容scroll的方向肯定是不同的,很好判断,如果相同的话... ╮(╯▽╰)╭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants