mirror of https://github.com/ElemeFE/element
Loading: use getStyle
parent
a0f0602f4c
commit
93910da173
|
@ -8,8 +8,8 @@ exports.install = Vue => {
|
||||||
if (binding.value) {
|
if (binding.value) {
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
if (binding.modifiers.fullscreen) {
|
if (binding.modifiers.fullscreen) {
|
||||||
el.originalPosition = document.body.style.position;
|
el.originalPosition = getStyle(document.body, 'position');
|
||||||
el.originalOverflow = document.body.style.overflow;
|
el.originalOverflow = getStyle(document.body, 'overflow');
|
||||||
|
|
||||||
addClass(el.mask, 'is-fullscreen');
|
addClass(el.mask, 'is-fullscreen');
|
||||||
insertDom(document.body, el, binding);
|
insertDom(document.body, el, binding);
|
||||||
|
@ -17,7 +17,7 @@ exports.install = Vue => {
|
||||||
removeClass(el.mask, 'is-fullscreen');
|
removeClass(el.mask, 'is-fullscreen');
|
||||||
|
|
||||||
if (binding.modifiers.body) {
|
if (binding.modifiers.body) {
|
||||||
el.originalPosition = document.body.style.position;
|
el.originalPosition = getStyle(document.body, 'position');
|
||||||
|
|
||||||
['top', 'left'].forEach(property => {
|
['top', 'left'].forEach(property => {
|
||||||
let scroll = property === 'top' ? 'scrollTop' : 'scrollLeft';
|
let scroll = property === 'top' ? 'scrollTop' : 'scrollLeft';
|
||||||
|
@ -29,7 +29,7 @@ exports.install = Vue => {
|
||||||
|
|
||||||
insertDom(document.body, el, binding);
|
insertDom(document.body, el, binding);
|
||||||
} else {
|
} else {
|
||||||
el.originalPosition = el.style.position;
|
el.originalPosition = getStyle(el, 'position');
|
||||||
insertDom(el, el, binding);
|
insertDom(el, el, binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ exports.install = Vue => {
|
||||||
el.mask.style[property] = el.maskStyle[property];
|
el.mask.style[property] = el.maskStyle[property];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (el.originalPosition !== 'absolute') {
|
if (el.originalPosition !== 'absolute' && el.originalPosition !== 'fixed') {
|
||||||
parent.style.position = 'relative';
|
parent.style.position = 'relative';
|
||||||
}
|
}
|
||||||
if (binding.modifiers.fullscreen && binding.modifiers.lock) {
|
if (binding.modifiers.fullscreen && binding.modifiers.lock) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import loadingVue from './loading.vue';
|
import loadingVue from './loading.vue';
|
||||||
|
import { getStyle } from 'element-ui/src/utils/dom';
|
||||||
import merge from 'element-ui/src/utils/merge';
|
import merge from 'element-ui/src/utils/merge';
|
||||||
|
|
||||||
const LoadingConstructor = Vue.extend(loadingVue);
|
const LoadingConstructor = Vue.extend(loadingVue);
|
||||||
|
@ -41,10 +42,10 @@ LoadingConstructor.prototype.close = function() {
|
||||||
const addStyle = (options, parent, instance) => {
|
const addStyle = (options, parent, instance) => {
|
||||||
let maskStyle = {};
|
let maskStyle = {};
|
||||||
if (options.fullscreen) {
|
if (options.fullscreen) {
|
||||||
instance.originalPosition = document.body.style.position;
|
instance.originalPosition = getStyle(document.body, 'position');
|
||||||
instance.originalOverflow = document.body.style.overflow;
|
instance.originalOverflow = getStyle(document.body, 'overflow');
|
||||||
} else if (options.body) {
|
} else if (options.body) {
|
||||||
instance.originalPosition = document.body.style.position;
|
instance.originalPosition = getStyle(document.body, 'position');
|
||||||
['top', 'left'].forEach(property => {
|
['top', 'left'].forEach(property => {
|
||||||
let scroll = property === 'top' ? 'scrollTop' : 'scrollLeft';
|
let scroll = property === 'top' ? 'scrollTop' : 'scrollLeft';
|
||||||
maskStyle[property] = options.target.getBoundingClientRect()[property] +
|
maskStyle[property] = options.target.getBoundingClientRect()[property] +
|
||||||
|
@ -56,7 +57,7 @@ const addStyle = (options, parent, instance) => {
|
||||||
maskStyle[property] = options.target.getBoundingClientRect()[property] + 'px';
|
maskStyle[property] = options.target.getBoundingClientRect()[property] + 'px';
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
instance.originalPosition = parent.style.position;
|
instance.originalPosition = getStyle(parent, 'position');
|
||||||
}
|
}
|
||||||
Object.keys(maskStyle).forEach(property => {
|
Object.keys(maskStyle).forEach(property => {
|
||||||
instance.$el.style[property] = maskStyle[property];
|
instance.$el.style[property] = maskStyle[property];
|
||||||
|
@ -86,7 +87,7 @@ const Loading = (options = {}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
addStyle(options, parent, instance);
|
addStyle(options, parent, instance);
|
||||||
if (instance.originalPosition !== 'absolute') {
|
if (instance.originalPosition !== 'absolute' && instance.originalPosition !== 'fixed') {
|
||||||
parent.style.position = 'relative';
|
parent.style.position = 'relative';
|
||||||
}
|
}
|
||||||
if (options.fullscreen && options.lock) {
|
if (options.fullscreen && options.lock) {
|
||||||
|
|
Loading…
Reference in New Issue