Adding overflow:hidden to the body when "scrollable" is enabled. #71

This commit is contained in:
euvl
2017-09-07 15:43:58 +01:00
parent 97e950a52e
commit b5642b8bd6
4 changed files with 58 additions and 16 deletions

23
dist/index.js vendored

File diff suppressed because one or more lines are too long

23
dist/ssr.index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
{
"name": "vue-js-modal",
"description": "Modal Component for Vue.js",
"version": "1.2.9",
"version": "1.2.10",
"author": "euvl <yev.vlasenko@gmail.com>",
"main": "dist/index.js",
"repository": {

View File

@@ -369,7 +369,7 @@
* Event handler which is triggered on $modal.show and $modal.hight
*/
toggle (state, params) {
const { reset, visible } = this
const { reset, scrollable, visible } = this
const beforeEventName = visible
? 'before-close'
@@ -379,10 +379,22 @@
? 'closed'
: 'opened'
if (beforeEventName === 'before-open' && reset) {
this.setInitialSize()
this.shift.left = 0
this.shift.top = 0
if (beforeEventName === 'before-open') {
if (reset) {
this.setInitialSize()
this.shift.left = 0
this.shift.top = 0
}
if (scrollable) {
document.body.classList.add('v--modal-block-scroll')
}
}
if (beforeEventName === 'before-close') {
if (scrollable) {
document.body.classList.remove('v--modal-block-scroll')
}
}
let stopEventExecution = false
@@ -489,6 +501,10 @@
}
</script>
<style>
.v--modal-block-scroll {
overflow: hidden;
}
.v--modal-overlay {
position: fixed;
box-sizing: border-box;