liyongli il y a 1 an
Parent
commit
744f3fe2ed
1 fichiers modifiés avec 5 ajouts et 17 suppressions
  1. 5 17
      src/view/schedule/index.vue

+ 5 - 17
src/view/schedule/index.vue

@@ -146,11 +146,10 @@ const touchstart = e => {
 
 const touchend = e => {
   const cha = startY - e.changedTouches[0].clientY;
-  console.log(1)
   if (!isChangePage(cha)) return;
   //  cha > 0    向上滑动手指
   //  cha < 0    向下滑动手指
-  if (cha <= 0 && cha >= -50) return;
+  console.log(cha);
   if (cha > 0 && cha < 100) return;
   // 距离足够则滑动到下一页;
   let n = cha > 0 ? 1 : -1;
@@ -161,23 +160,11 @@ const touchend = e => {
   if (dn > len) return (dn = 0);
   page.value = dn;
   nextTick(() => {
-    let nodes = main.value.childNodes || [];
-    let sondiv = null;
-    for (let i = 0; i < nodes.length; i++) {
-      const ele = nodes[i];
-      if (ele.localName !== 'div') continue;
-      if (sondiv) break;
-      sondiv = ele;
-    }
-    let t = setTimeout(() => {
-      sondiv.scrollTop = 0;
-
-      clearTimeout(t);
-    }, 100);
+    main.value.scrollTop = 0;
   });
 };
 
-const touchmove = () => {
+const touchmove = e => {
   let nodes = main.value.childNodes || [];
   let sondiv = null;
   for (let i = 0; i < nodes.length; i++) {
@@ -186,7 +173,8 @@ const touchmove = () => {
     if (sondiv) break;
     sondiv = ele;
   }
-//   if (sondiv.scrollTop <= 1) e.preventDefault();
+  let h = main.value.offsetHeight + main.value.scrollTop;
+  if (main.value.scrollTop <= 1 && h > sondiv.offsetHeight + 10) e.preventDefault();
 };
 </script>
 <style lang="scss">