hsy-vue-dialog
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -589,4 +589,4 @@ module.exports = | ||
height: '', | ||
bodyOverflowX: '', | ||
bodyOverflowY: '', | ||
parentOverflowX: '', | ||
parentOverflowY: '', | ||
isHidden: true | ||
@@ -609,2 +609,6 @@ }; | ||
}, | ||
wholeWindow: { | ||
type: Boolean, | ||
default: true | ||
}, | ||
value: { | ||
@@ -618,2 +622,32 @@ type: Boolean, | ||
return this.$el.querySelector('.main'); | ||
}, | ||
parentEl: function parentEl() { | ||
var parent = this.$el.parentNode; | ||
while (parent) { | ||
if (parent === document.body) { | ||
break; | ||
} | ||
var style = window.getComputedStyle(parent); | ||
var position = style.getPropertyValue('position'); | ||
if (position === 'relative' || position === 'absolute') { | ||
break; | ||
} | ||
parent = parent.parentNode; | ||
} | ||
return parent; | ||
}, | ||
parentSize: { | ||
cache: false, | ||
get: function get() { | ||
if (this.wholeWindow) { | ||
var width = document.documentElement.clientWidth; | ||
var height = document.documentElement.clientHeight; | ||
return { | ||
width: width, | ||
height: height | ||
}; | ||
} | ||
return this.parentEl.getBoundingClientRect(); | ||
} | ||
} | ||
@@ -654,4 +688,5 @@ }, | ||
updateContainerSize: function updateContainerSize() { | ||
this.$el.style.width = document.documentElement.clientWidth + 'px'; | ||
this.$el.style.height = document.documentElement.clientHeight + 'px'; | ||
var size = this.parentSize; | ||
this.$el.style.width = size.width + 'px'; | ||
this.$el.style.height = size.height + 'px'; | ||
}, | ||
@@ -665,13 +700,13 @@ updateMainSize: function updateMainSize() { | ||
}, | ||
captureBodyOverflow: function captureBodyOverflow() { | ||
var style = window.getComputedStyle(document.body); | ||
this.bodyOverflowX = style.getPropertyValue('overflowX'); | ||
this.bodyOverflowY = style.getPropertyValue('overflowY'); | ||
captureParentOverflow: function captureParentOverflow() { | ||
var style = window.getComputedStyle(this.parentEl); | ||
this.parentOverflowX = style.getPropertyValue('overflowX'); | ||
this.parentOverflowY = style.getPropertyValue('overflowY'); | ||
}, | ||
forceBodyOverflow: function forceBodyOverflow() { | ||
document.body.style.overflow = 'hidden'; | ||
forceParentOverflow: function forceParentOverflow() { | ||
this.parentEl.overflow = 'hidden'; | ||
}, | ||
resumeBodyOverflow: function resumeBodyOverflow() { | ||
document.body.style.overflowX = this.bodyOverflowX; | ||
document.body.style.overflowY = this.bodyOverflowY; | ||
resumeParentOverflow: function resumeParentOverflow() { | ||
this.parentEl.style.overflowX = this.bodyOverflowX; | ||
this.parentEl.style.overflowY = this.bodyOverflowY; | ||
}, | ||
@@ -710,4 +745,4 @@ addCssClass: function addCssClass(el, cls) { | ||
this.$el.style.display = 'block'; | ||
this.captureBodyOverflow(); | ||
this.forceBodyOverflow(); | ||
this.captureParentOverflow(); | ||
this.forceParentOverflow(); | ||
this.updateContainerSize(); | ||
@@ -725,3 +760,3 @@ this.updateMainSize(); | ||
_this2.$el.style.display = 'none'; | ||
_this2.resumeBodyOverflow(); | ||
_this2.resumeParentOverflow(); | ||
_this2.$emit('input', false); | ||
@@ -735,2 +770,8 @@ _this2.isHidden = true; | ||
} | ||
}, | ||
mounted: function mounted() { | ||
if (this.wholeWindow) { | ||
this.$el.parentNode.removeChild(this.$el); | ||
document.body.appendChild(this.$el); | ||
} | ||
} | ||
@@ -737,0 +778,0 @@ }; |
{ | ||
"name": "hsy-vue-dialog", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "vue dialog component", | ||
@@ -5,0 +5,0 @@ "author": "hsiaosiyuan0 <hsiaosiyuan0@outlook.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40380
863