From 865f92f73583c7908a876fd1fa244ad08397a950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 21 Aug 2017 21:54:14 +0800 Subject: [PATCH] fix: popup will not preventScroll by default --- packages/mixins/popup/index.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/mixins/popup/index.js b/packages/mixins/popup/index.js index 95af13559..3cea8db79 100644 --- a/packages/mixins/popup/index.js +++ b/packages/mixins/popup/index.js @@ -4,16 +4,12 @@ import PopupContext from './popup-context'; export default { props: { - /** - * popup当前显示状态 - */ + // popup当前显示状态 value: { type: Boolean, default: false }, - /** - * 是否显示遮罩层 - */ + // 是否显示遮罩层 overlay: { type: Boolean, default: false @@ -26,13 +22,16 @@ export default { default: false }, zIndex: [String, Number], - /** - * popup滚动时是否body内容也滚动 - * 默认为不滚动 - */ + // popup滚动时是否body内容也滚动 + // 默认为不滚动 lockOnScroll: { type: Boolean, default: true + }, + // 防止滚动穿透 + preventScroll: { + type: Boolean, + default: false } }, @@ -137,8 +136,11 @@ export default { this.$el.style.zIndex = PopupManager.nextZIndex(); this.opened = true; this.opening = false; - document.addEventListener('touchstart', this.recordPosition, false); - document.addEventListener('touchmove', this.watchTouchMove, false); + + if (this.preventScroll) { + document.addEventListener('touchstart', this.recordPosition, false); + document.addEventListener('touchmove', this.watchTouchMove, false); + } }, /**