# wxPull **Repository Path**: LucasDot/wxPull ## Basic Information - **Project Name**: wxPull - **Description**: No description available - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-11-23 - **Last Updated**: 2021-11-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 原生JS实现微信公众号或网页使用下拉加载和上拉刷新 > 微信浏览器打开网页显示网址安全信息解决办法,网上很多办法,也找了很久,但是最新的很多用不了。 > 先看看效果,是不是亲想要的,可以跳过,以免浪费宝贵时间。用微信打开以下网址浏览效果(用微信打开):http://atigege.com/case/web/wxPull/  ## 我的解决思路: > 1、直接在样式表里的html和body上加上:touch-action:none; html,body{touch-action:none} > 2、然后把touch事件全部用js来处理。包括滚动条的移动也用JS来监听 ## 原理: ### 初始化配置pull.init() > init中调用extend方法,重置config的值 ### 监听touchstart,touchmove,touchend事件 #### 监听touchstart 1. 记录下开始滑动位置(this.status.start) 2. 记录下滑动时滚动条的位置(this.status.startScrollTop) 3. 清除滑动方向(this.status.direction) #### 监听touchmove 1. 记录下当前的位置(this.status.end) 2. 记录下手指位移值(this.status.offset) 3. 清除动画时间(this.setTransition(0)) 4. 当滚动条没有到底时,滑动只控制滚动条 5. 根据滑动的方向,确认方向,方向一旦赋值,在松开手指前不变更(this.status.direction) 6. 如果方向向上,执行this.touchMoveUp(); 7. 如果方向向下,执行this.couchMoveDown(); #### 监听touchEnd 1. 根据方向,this.status.direction="down"时,执行向上this.touchEndDown(); 2. 根据方向,this.status.direction="up"时,执行向上this.touchEndUp(); 3. 设置this.status.isCanMove=false; 4. this.setTransition(1),把动画时间设为1秒 5. this.back(0)复位对象。 ## 使用方法 #### 禁用touch-action > html,body{touch-action:none} #### 添加HTML元素 > 1. 下拉刷新提示容器:`