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/08/10 02:48:41 UTC

[10/12] incubator-weex git commit: * [html5] rm transitionend listener for toast.

* [html5] rm transitionend listener for toast.


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

Branch: refs/heads/0.16-dev
Commit: e3beff06299e197eeb0dfd1e2f80d2e409e04ab7
Parents: d3da1f9
Author: MrRaindrop <te...@gmail.com>
Authored: Mon Aug 7 17:04:02 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Mon Aug 7 17:04:02 2017 +0800

----------------------------------------------------------------------
 html5/render/vue/modules/modal/toast.js | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e3beff06/html5/render/vue/modules/modal/toast.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/modules/modal/toast.js b/html5/render/vue/modules/modal/toast.js
index d8e310a..da44424 100644
--- a/html5/render/vue/modules/modal/toast.js
+++ b/html5/render/vue/modules/modal/toast.js
@@ -20,15 +20,11 @@ const queue = []
 let isProcessing = false
 let toastWin
 const TOAST_WIN_CLASS_NAME = 'weex-toast'
+const TOAST_TRANSITION_DURATION = 0.4
 
 const DEFAULT_DURATION = 0.8
 
 function showToastWindow (msg, callback) {
-  const handleTransitionEnd = function () {
-    toastWin.removeEventListener('transitionend', handleTransitionEnd)
-    toastWin.removeEventListener('webkitTransitionEnd', handleTransitionEnd)
-    callback && callback()
-  }
   if (!toastWin) {
     toastWin = document.createElement('div')
     toastWin.classList.add(TOAST_WIN_CLASS_NAME)
@@ -36,27 +32,20 @@ function showToastWindow (msg, callback) {
     document.body.appendChild(toastWin)
   }
   toastWin.textContent = msg
-  toastWin.addEventListener('transitionend', handleTransitionEnd)
-  toastWin.addEventListener('webkitTransitionEnd', handleTransitionEnd)
   setTimeout(function () {
     toastWin.classList.remove('hide')
+    callback && callback()
   }, 16)
 }
 
 function hideToastWindow (callback) {
-  const handleTransitionEnd = function () {
-    toastWin.removeEventListener('transitionend', handleTransitionEnd)
-    toastWin.removeEventListener('webkitTransitionEnd', handleTransitionEnd)
-    callback && callback()
-  }
   if (!toastWin) {
     return
   }
-  toastWin.addEventListener('transitionend', handleTransitionEnd)
-  toastWin.addEventListener('webkitTransitionEnd', handleTransitionEnd)
+  toastWin.classList.add('hide')
   setTimeout(function () {
-    toastWin.classList.add('hide')
-  }, 16)
+    callback && callback()
+  }, TOAST_TRANSITION_DURATION * 1000)
 }
 
 export default {