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

如何才能横向滚动时锁定页面纵向滚动事件呢? #2

Open
baranwang opened this issue Jan 7, 2018 · 2 comments
Open

Comments

@baranwang
Copy link

如何才能横向滚动时锁定页面纵向滚动事件呢?现在翻着翻着页面就跑了……

@im55cc
Copy link

im55cc commented Dec 8, 2018

我也遇到了这个问题,请问你是怎么解决的呢?

@im55cc
Copy link

im55cc commented Dec 9, 2018

看了一下源码,
我是这么解决的,在 onTouchMove 回调函数里,判断滑动距离小于设备高度或宽度的一半,抛出一个异常,
虽然感觉不太优雅,但好歹能解决问题了,哈哈。

onTouchMove (weswiper, event) {
          const { XORY } = weswiper
          const touch = event.changedTouches[0]
          const distance = touch[`client${XORY}`]
          const tmpMove = distance - weswiper[`touchStart${XORY}`]
          if (Math.abs(tmpMove) <= (weswiper.rectDistance / 2)) {
            console.log(weswiper.rectDistance / 2)
            throw new Error('')
          }
        },

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

2 participants