|
@@ -159,7 +159,8 @@ let startY = 0
|
|
|
let moveX = 0
|
|
|
let moveY = 0
|
|
|
|
|
|
-let hwoLong = 1000
|
|
|
+let timeout: number
|
|
|
+
|
|
|
const touchstart = (e: TouchEvent) => {
|
|
|
// 如果你要阻止点击事件,请反注释下一行代码
|
|
|
// e.preventDefault()
|
|
@@ -174,16 +175,33 @@ const touchmove = (e: TouchEvent) => {
|
|
|
if (startX - moveX <= -100) { // 右滑触发
|
|
|
// do something
|
|
|
if (currentSubjectIndex.value == 0) {
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (timeout) {
|
|
|
return
|
|
|
}
|
|
|
- currentSubjectIndex.value = currentSubjectIndex.value - 1
|
|
|
+ window.clearTimeout(timeout)
|
|
|
+ timeout = window.setTimeout(() => {
|
|
|
+ currentSubjectIndex.value = currentSubjectIndex.value - 1
|
|
|
+ timeout=0
|
|
|
+ }, 750)
|
|
|
+
|
|
|
}
|
|
|
- if (startX - moveX <= 100) { // 左滑触发
|
|
|
+ if (startX - moveX >= 100) { // 左滑触发
|
|
|
// do something
|
|
|
if ((subjectList.value.length - 1) == currentSubjectIndex.value) {
|
|
|
return
|
|
|
}
|
|
|
- currentSubjectIndex.value = currentSubjectIndex.value + 1
|
|
|
+ if (timeout) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ window.clearTimeout(timeout)
|
|
|
+ timeout = window.setTimeout(() => {
|
|
|
+ currentSubjectIndex.value = currentSubjectIndex.value + 1
|
|
|
+ timeout=0
|
|
|
+ }, 750)
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|