You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ta...@apache.org on 2017/05/25 02:45:59 UTC

[17/50] incubator-weex git commit: * [html5] use tap for click event since click has 300ms latency in ios.

* [html5] use tap for click event since click has 300ms latency in ios.


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

Branch: refs/heads/0.13-dev
Commit: 04147374ae00838c9e8d7ac7f58dbedb2bac14d1
Parents: 910546e
Author: MrRaindrop <te...@gmail.com>
Authored: Tue May 9 17:52:43 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Tue May 9 17:52:43 2017 +0800

----------------------------------------------------------------------
 .../render/vue/components/slider/slideMixin.js  |  6 +-
 html5/render/vue/core/node.js                   | 62 ++++++++++++--------
 html5/render/vue/mixins/scrollable.js           |  6 +-
 3 files changed, 43 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/04147374/html5/render/vue/components/slider/slideMixin.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/slider/slideMixin.js b/html5/render/vue/components/slider/slideMixin.js
index 3aef972..314a377 100644
--- a/html5/render/vue/components/slider/slideMixin.js
+++ b/html5/render/vue/components/slider/slideMixin.js
@@ -179,7 +179,7 @@ export default {
     },
 
     handleTouchStart (event) {
-      event.stopPropagation()
+      // event.stopPropagation()
       const touch = event.changedTouches[0]
       this._touchParams = {
         originalTransform: this.$refs.inner.style.webkitTransform || this.$refs.inner.style.transform,
@@ -191,7 +191,7 @@ export default {
     },
 
     handleTouchMove (event) {
-      event.stopPropagation()
+      // event.stopPropagation()
       const tp = this._touchParams
       if (!tp) { return }
       const { startX, startY } = this._touchParams
@@ -225,7 +225,7 @@ export default {
     },
 
     handleTouchEnd (event) {
-      event.stopPropagation()
+      // event.stopPropagation()
       const tp = this._touchParams
       if (!tp) { return }
       const isV = tp.isVertical

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/04147374/html5/render/vue/core/node.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/core/node.js b/html5/render/vue/core/node.js
index e9a28df..746f3c6 100644
--- a/html5/render/vue/core/node.js
+++ b/html5/render/vue/core/node.js
@@ -17,6 +17,8 @@
  * under the License.
  */
 
+import { extend } from '../utils'
+
 /**
  * remove text nodes in the nodes array.
  * @param  {Array} nodes
@@ -52,7 +54,7 @@ function getListeners (vnode, evt) {
 }
 
 const supportedEvents = [
-  'click', 'longpress', 'appear', 'disappear',
+  'longpress', 'appear', 'disappear',
   // 'touchstart', 'touchmove', 'touchend',
   'panstart', 'panmove', 'panend', 'swipe', 'longpress'
 ]
@@ -63,34 +65,44 @@ const supportedEvents = [
  */
 export function createEventMap (context, extras = []) {
   const eventMap = {}
-  supportedEvents.concat(extras).forEach(name => {
-    eventMap[name] = function (e) {
-      // no original bubbling.
-      e.stopPropagation()
-      // but should trigger the closest parent which has bound the
-      // event handler.
-      let vm = context
-      while (vm) {
-        const ons = getListeners(vm.$vnode, name)
-        const len = ons.length
-        let idx = 0
-        while (idx < len) {
-          let on = ons[idx]
-          if (on && on.fn) {
-            on = on.fn
+  /**
+   * bind name with evt event. e.g. bind 'click' with 'tap' event.
+   */
+  const bindFunc = (evt) => {
+    return name => {
+      const evtType = evt || name
+      eventMap[evtType] = function (e) {
+        // no original bubbling.
+        e.stopPropagation()
+        // but should trigger the closest parent which has bound the
+        // event handler.
+        let vm = context
+        while (vm) {
+          const ons = getListeners(vm.$vnode, name)
+          const len = ons.length
+          let idx = 0
+          while (idx < len) {
+            let on = ons[idx]
+            if (on && on.fn) {
+              on = on.fn
+            }
+            on && on.call(vm,
+              evtType === name ? e : extend({}, e, { type: name })
+            )
+            idx++
           }
-          on && on.call(vm, e)
-          idx++
-        }
 
-        // once a parent node (or self node) has triggered the handler,
-        // then it stops bubble immediately.
-        if (len > 0) {
-          return
+          // once a parent node (or self node) has triggered the handler,
+          // then it stops bubble immediately.
+          if (len > 0) {
+            return
+          }
+          vm = vm.$parent
         }
-        vm = vm.$parent
       }
     }
-  })
+  }
+  supportedEvents.concat(extras).forEach(bindFunc())
+  bindFunc('tap')('click')
   return eventMap
 }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/04147374/html5/render/vue/mixins/scrollable.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/mixins/scrollable.js b/html5/render/vue/mixins/scrollable.js
index 45a9853..b0a84de 100644
--- a/html5/render/vue/mixins/scrollable.js
+++ b/html5/render/vue/mixins/scrollable.js
@@ -110,7 +110,7 @@ export default {
 
     handleTouchStart (event) {
       // event.preventDefault()
-      event.stopPropagation()
+      // event.stopPropagation()
       if (this._loading || this._refresh) {
         const touch = event.changedTouches[0]
         this._touchParams = {
@@ -126,7 +126,7 @@ export default {
 
     handleTouchMove (event) {
       // event.preventDefault()
-      event.stopPropagation()
+      // event.stopPropagation()
       if (this._touchParams) {
         const inner = this.$refs.inner
         const { startY, reachTop, reachBottom } = this._touchParams
@@ -146,7 +146,7 @@ export default {
 
     handleTouchEnd (event) {
       // event.preventDefault()
-      event.stopPropagation()
+      // event.stopPropagation()
       if (this._touchParams) {
         const inner = this.$refs.inner
         const { reachTop, reachBottom } = this._touchParams