Updated demo, moved "adapt" controller into function

This commit is contained in:
euvl
2017-05-01 14:33:41 +03:00
parent f518f5849e
commit 393ea38104
5 changed files with 43 additions and 19 deletions

View File

@@ -116,6 +116,7 @@
visible (value) {
if (value) {
this.visibility.overlay = true
this.adaptSize()
setTimeout(() => {
this.visibility.modal = true
@@ -186,11 +187,7 @@
onWindowResize () {
this.window.width = window.innerWidth
this.window.height = window.innerHeight
if (this.adaptive) {
this.modal.width = inRange(0, this.window.width, this.modal.width)
this.modal.height = inRange(0, this.window.height, this.modal.height)
}
this.adaptSize()
},
genEventObject (params) {
@@ -202,6 +199,13 @@
}, params || {});
},
adaptSize () {
if (this.adaptive) {
this.modal.width = inRange(0, this.window.width, this.modal.width)
this.modal.height = inRange(0, this.window.height, this.modal.height)
}
},
resize (event) {
this.modal.width = event.size.width
this.modal.height = event.size.height
@@ -285,7 +289,7 @@
},
removeDraggableListeners () {
console.log('removing draggable handlers')
// console.log('removing draggable handlers')
}
}
};

View File

@@ -1,9 +1,11 @@
export const inRange = (from, to, value) => {
if (value > to) {
return to
}
if (value < from) {
return from
}
if (value > to) {
return to
}
return value
}