This commit is contained in:
cookfront 2017-02-16 16:54:15 +08:00
parent 3a1fca4953
commit c45822b400
4 changed files with 21 additions and 5 deletions

View File

@ -19,7 +19,6 @@
<script>
import Popup from 'packages/popup';
import PopupManager from 'src/mixins/popup/popup-manager';
const CANCEL_TEXT = '取消';
const CONFIRM_TEXT = '确认';

View File

@ -57,7 +57,7 @@ export default {
beforeMount() {
if (this.transition !== 'popup-fade') {
this.currentTransition = `popup-slide-${ this.position }`;
this.currentTransition = `popup-slide-${this.position}`;
}
},

View File

@ -74,9 +74,9 @@ export default {
value(val) {
if (val) {
if (this.opening) return;
this.open();
} else {
if (this.closing) return;
this.close();
}
}
@ -125,13 +125,18 @@ export default {
this.closing = false;
}
PopupManager.openModal(this._popupId, PopupManager.nextZIndex(), dom);
// 如果滚动时需要锁定
if (props.lockOnScroll) {
// 将原来的`bodyOverflow`和`bodyPaddingRight`存起来
if (!this.bodyOverflow) {
this.bodyPaddingRight = document.body.style.paddingRight;
this.bodyOverflow = document.body.style.overflow;
}
scrollBarWidth = getScrollBarWidth();
// 页面是否`overflow`
let bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
if (scrollBarWidth > 0 && bodyHasOverflow) {
document.body.style.paddingRight = scrollBarWidth + 'px';

View File

@ -1,4 +1,17 @@
/* istanbul ignore next */
const trim = function(string) {
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
};
export function hasClass(el, cls) {
if (!el || !cls) return false;
if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
if (el.classList) {
return el.classList.contains(cls);
} else {
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
};
export function addClass(el, cls) {
if (!el) return;
var curClass = el.className;
@ -21,7 +34,6 @@ export function addClass(el, cls) {
}
};
/* istanbul ignore next */
export function removeClass(el, cls) {
if (!el || !cls) return;
var classes = cls.split(' ');