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

View File

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