weui / react-weui

weui for react
https://weui.github.io/react-weui/docs/
2.85k stars 493 forks source link

Fix swiper `TouchMove` to normal page scrolling caused by `preventDef… #298

Open dawiwt opened 5 years ago

dawiwt commented 5 years ago

修复 Swiper handleTouchMove 事件中的 preventDefault 导致页面不能正常滚动的问题。

  1. 在 handleTouchStart 记录起始触摸点
  2. 在 handleTouchMove 中计算横向与纵向触摸移动距离
  3. 分别比较横向与纵向移动距离来判断用户滚动意向,满足当前 direction 才对 diff 求值
  4. 比较 diff 与 translate 来决定是否 preventDefault 并且更新 translate
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.5%) to 81.029% when pulling 26bda65d48494cded5ec724ae1f24f0895b2b7c8 on dawiwt:master into f8b12cd6f383b3e07c64442623839376384e33d0 on weui:master.