From b2b0057ac9b8d6d06d75bbc76f42f27acf241a72 Mon Sep 17 00:00:00 2001 From: Jackson Date: Thu, 16 Nov 2017 15:35:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=87=E7=BA=A7sidebar=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=8A=A0=E5=85=A5=20mask=20=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E5=B0=8F=E5=A7=91=20(#895)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mip-sidebar/mip-sidebar.js | 32 ++++++++++++++++++++++++++++---- src/mip-sidebar/mip-sidebar.less | 2 +- src/mip-sidebar/package.json | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/mip-sidebar/mip-sidebar.js b/src/mip-sidebar/mip-sidebar.js index 1d564d269..935bc1f49 100644 --- a/src/mip-sidebar/mip-sidebar.js +++ b/src/mip-sidebar/mip-sidebar.js @@ -8,6 +8,7 @@ define(function (require) { var customElement = require('customElement').create(); var util = require('util'); + var naboo = util.naboo; /** * [toggle 打开或关闭 sidebar 入口] @@ -24,6 +25,10 @@ define(function (require) { function open() { var self = this; + if (self.runing) { + return; + } + self.runing = true; if (isOpen.call(this)) { return; @@ -55,6 +60,10 @@ define(function (require) { function close(event) { var self = this; + if (self.runing) { + return; + } + self.runing = true; event.preventDefault(); self.element.removeAttribute('open'); @@ -102,16 +111,31 @@ define(function (require) { self.maskElement.setAttribute('on', 'tap:' + self.id + '.close'); // 样式设置 - util.css(self.maskElement, {display: 'block'}); - + self.maskElement.style.display = 'block'; + + naboo.animate(self.maskElement, { + opacity: 0.2 + }, { + duration: 500 + }).start(function () { + self.runing = false; + }); } /** * [closeMask 关闭遮盖层] */ function closeMask() { - if (this.maskElement) { - util.css(this.maskElement, {display: 'none'}); + var self = this; + if (self.maskElement) { + naboo.animate(self.maskElement, { + opacity: 0 + }, { + duration: 500 + }).start(function () { + self.maskElement.style.display = 'none'; + self.runing = false; + }); } } diff --git a/src/mip-sidebar/mip-sidebar.less b/src/mip-sidebar/mip-sidebar.less index 0ccd3fc45..c3b35eac6 100644 --- a/src/mip-sidebar/mip-sidebar.less +++ b/src/mip-sidebar/mip-sidebar.less @@ -43,7 +43,7 @@ mip-sidebar[side][open] { left: 0!important; width: 100%!important; height: 100%!important; - opacity: 0.2; + opacity: 0; background-image: none!important; background-color: #000; z-index: 9998!important; diff --git a/src/mip-sidebar/package.json b/src/mip-sidebar/package.json index 350199e15..a066297b5 100644 --- a/src/mip-sidebar/package.json +++ b/src/mip-sidebar/package.json @@ -1,6 +1,6 @@ { "name": "mip-sidebar", - "version": "1.1.6", + "version": "1.1.7", "description": "侧边栏组件,点击按钮,侧边栏滑入屏幕。", "contributors": [ {