class SwipeHandler {
    constructor() {
      this.startY = 0;
      this.endY = 0;
      this.startTime = 0;
      this.endTime = 0;
    }
  
    onTouchStart(e) {
      this.startY = e.touches[0].clientY;
      this.startTime = Date.now();
    }
  
    onTouchMove(e) {
      // 在这里可以更新Y坐标，但通常只需要开始和结束时的坐标
    }
  
    onTouchEnd(e) {
      this.endY = e.changedTouches[0].clientY;
      this.endTime = Date.now();
  
      const distanceThreshold = 150; // 设置滑动距离阈值，单位：像素
      const timeThreshold = 200; // 设置时间阈值，单位：毫秒
  
      const distance = this.startY - this.endY;
      const duration = this.endTime - this.startTime;
  
      if (Math.abs(distance) > distanceThreshold && duration < timeThreshold) {
        if (distance > 0) {
          // 向上滑动
          console.log('向上滑动');
          return 'up'
        } else {
          // 向下滑动
          console.log('向下滑动');
          return 'down'
        }
      }
    }
}
export default SwipeHandler
/*   const swipeHandler = new SwipeHandler();
  
  Page({
    data: {},
    onTouchStart: function(e) {
      swipeHandler.onTouchStart(e);
    },
    onTouchMove: function(e) {
      swipeHandler.onTouchMove(e);
    },
    onTouchEnd: function(e) {
      swipeHandler.onTouchEnd(e);
    }
  }); */