* [html5] fix loading & refresh: pullingdown wrongly triggered.

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/56df42dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/56df42dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/56df42dd

Branch: refs/heads/master
Commit: 56df42ddc13c18ad960c6ef7f4e5c1f9e51d9997
Parents: babd33b
Author: MrRaindrop <tekk...@gmail.com>
Authored: Fri Sep 15 15:47:12 2017 +0800
Committer: MrRaindrop <tekk...@gmail.com>
Committed: Fri Sep 15 15:47:12 2017 +0800

----------------------------------------------------------------------
 .../components/scrollable/mixins/scrollable.js  | 53 +++++++++++---------
 1 file changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/56df42dd/html5/render/vue/components/scrollable/mixins/scrollable.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/scrollable/mixins/scrollable.js 
b/html5/render/vue/components/scrollable/mixins/scrollable.js
index 8f39580..19ffe74 100644
--- a/html5/render/vue/components/scrollable/mixins/scrollable.js
+++ b/html5/render/vue/components/scrollable/mixins/scrollable.js
@@ -225,34 +225,41 @@ export default {
     },
 
     handleTouchMove (event) {
-      if (this._touchParams) {
-        const inner = this.$refs.inner
-        const { startY, reachTop, reachBottom } = this._touchParams
-        if (inner) {
-          const touch = event.changedTouches[0]
-          const offsetY = touch.pageY - startY
-          this._touchParams.offsetY = offsetY
-          if (reachTop && this._refresh) {
-            this._refresh.pullingDown(offsetY)
-          }
-          else if (reachBottom && this._loading) {
-            this._loading.pullingUp(-offsetY)
-          }
+      if (!this._touchParams || !this._refresh && !this._loading) {
+        return
+      }
+      const inner = this.$refs.inner
+      const { startY, reachTop, reachBottom } = this._touchParams
+      if (inner) {
+        const touch = event.changedTouches[0]
+        const offsetY = touch.pageY - startY
+        const dir = offsetY > 0 ? 'down' : 'up'
+        this._touchParams.offsetY = offsetY
+        if (this._refresh && (dir === 'down') && reachTop) {
+          this._refresh.pullingDown(offsetY)
+        }
+        else if (this._loading && (dir === 'up') && reachBottom) {
+          this._loading.pullingUp(-offsetY)
         }
       }
     },
 
     handleTouchEnd (event) {
-      if (this._touchParams) {
-        const inner = this.$refs.inner
-        const { reachTop, reachBottom } = this._touchParams
-        if (inner) {
-          if (reachTop && this._refresh) {
-            this._refresh.pullingEnd()
-          }
-          else if (reachBottom && this._loading) {
-            this._loading.pullingEnd()
-          }
+      if (!this._touchParams || !this._refresh && !this._loading) {
+        return
+      }
+      const inner = this.$refs.inner
+      const { startY, reachTop, reachBottom } = this._touchParams
+      if (inner) {
+        const touch = event.changedTouches[0]
+        const offsetY = touch.pageY - startY
+        const dir = offsetY > 0 ? 'down' : 'up'
+        this._touchParams.offsetY = offsetY
+        if (this._refresh && (dir === 'down') && reachTop) {
+          this._refresh.pullingEnd()
+        }
+        else if (this._loading && (dir === 'up') && reachBottom) {
+          this._loading.pullingEnd()
         }
       }
       delete this._touchParams

Reply via email to