From 232b71d802bf034f9d5ab173390db63fa8b5fffa Mon Sep 17 00:00:00 2001 From: wanglin Date: Wed, 21 Jun 2017 16:43:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=B1=82popup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/popup/index.vue | 13 +++++++++++-- src/components/popup/metas.yml | 6 +++++- src/components/popup/popup.js | 26 +++++++++++--------------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/popup/index.vue b/src/components/popup/index.vue index 10b3bba4d..0e8588cce 100755 --- a/src/components/popup/index.vue +++ b/src/components/popup/index.vue @@ -74,18 +74,26 @@ export default { for (let i = 0; i < this.$overflowScrollingList.length; i++) { this.$overflowScrollingList[i].style.webkitOverflowScrolling = type } + }, + updateZIndex () { + window.popupIndex = window.popupIndex || 250 + window.popupIndex += 1 + this.showIndex = window.popupIndex * 2 + 1 } }, data () { return { initialShow: true, hasFirstShow: false, - show: this.value + show: this.value, + showIndex: 501 } }, computed: { styles () { - const styles = {} + const styles = { + 'z-index': this.showIndex + } if (!this.position || this.position === 'bottom' || this.position === 'top') { styles.height = this.height } else { @@ -107,6 +115,7 @@ export default { show (val) { this.$emit('input', val) if (val) { + this.updateZIndex() this.popup && this.popup.show() this.$emit('on-show') this.fixSafariOverflowScrolling('auto') diff --git a/src/components/popup/metas.yml b/src/components/popup/metas.yml index 99ac7da30..230ce9308 100644 --- a/src/components/popup/metas.yml +++ b/src/components/popup/metas.yml @@ -113,4 +113,8 @@ changes: - '[fix] Fix overflow-scrolling setting in safari #311 @linhaobin' zh-CN: - '[fix] 修复 `overflow-scrolling` 设置逻辑遗漏问题 #311 @linhaobin' - + next: + en: + - '[feature] Support multiple popup' + zh-CN: + - '[feature] 支持多层popup' diff --git a/src/components/popup/popup.js b/src/components/popup/popup.js index 170ce443a..89c8fdfe2 100755 --- a/src/components/popup/popup.js +++ b/src/components/popup/popup.js @@ -11,13 +11,11 @@ const popupDialog = function (option) { showMask: option.showMask } } - if (!!document.querySelectorAll('.vux-popup-mask').length <= 0) { - this.divMask = document.createElement('a') - this.divMask.className = 'vux-popup-mask' - this.divMask.dataset.uuid = '' - this.divMask.href = 'javascript:void(0)' - document.body.appendChild(this.divMask) - } + this.divMask = document.createElement('a') + this.divMask.className = 'vux-popup-mask' + this.divMask.dataset.uuid = '' + this.divMask.href = 'javascript:void(0)' + document.body.appendChild(this.divMask) let div if (!option.container) { div = document.createElement('div') @@ -36,7 +34,7 @@ const popupDialog = function (option) { document.body.appendChild(div) } this.container = document.querySelector('.vux-popup-dialog-' + this.uuid) - this.mask = document.querySelector('.vux-popup-mask') + this.mask = this.divMask this.mask.dataset.uuid += `,${this.uuid}` this._bindEvents() option = null @@ -64,7 +62,7 @@ popupDialog.prototype._bindEvents = function () { popupDialog.prototype.show = function () { if (this.params.showMask) { this.mask.classList.add('vux-popup-show') - this.mask.style['zIndex'] = 500 + this.mask.style['zIndex'] = (window.popupIndex || 250) * 2 } this.container.classList.add('vux-popup-show') this.params.onOpen && this.params.onOpen(this) @@ -73,12 +71,10 @@ popupDialog.prototype.show = function () { popupDialog.prototype.hide = function (shouldCallback = true) { this.container.classList.remove('vux-popup-show') - if (!document.querySelector('.vux-popup-dialog.vux-popup-show')) { - this.mask.classList.remove('vux-popup-show') - setTimeout(() => { - this.mask && !/show/.test(this.mask.className) && (this.mask.style['zIndex'] = -1) - }, 400) - } + this.mask.classList.remove('vux-popup-show') + setTimeout(() => { + this.mask && !/show/.test(this.mask.className) && (this.mask.style['zIndex'] = -1) + }, 400) shouldCallback === false && this.params.onClose && this.params.hideOnBlur && this.params.onClose(this) this.isShow = false delete window.__$vuxPopups[this.uuid] From 95f478af43071c9e930f9366c8f1c2e0679f45b0 Mon Sep 17 00:00:00 2001 From: wanglin Date: Fri, 23 Jun 2017 16:34:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=A4=9A=E5=B1=82popup=E7=9A=84demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/demos/Popup.vue | 81 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/src/demos/Popup.vue b/src/demos/Popup.vue index 514fafc6f..57a15304c 100755 --- a/src/demos/Popup.vue +++ b/src/demos/Popup.vue @@ -10,7 +10,7 @@ - +
@@ -23,7 +23,7 @@
You did it! - +
@@ -33,7 +33,7 @@
- +
@@ -43,7 +43,7 @@
- +
@@ -55,7 +55,7 @@
- +
@@ -66,7 +66,7 @@
- +
@@ -77,7 +77,7 @@
- +
@@ -94,7 +94,7 @@ - +
@@ -124,7 +124,7 @@
- +
@@ -170,11 +170,41 @@
+ + + + +
+ +
+ +
+ 确定 +
+
+
+
+ +
+ +
+ + + + + +
+ 提交 +
+
+
+
+