mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Updated demo, moved "adapt" controller into function
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
<title>Vue Modal Examples</title>
|
<title>Vue Modal Examples</title>
|
||||||
<meta name="description" content="Vue.js modal component. Simple, clean with no external dependencies."/>
|
<meta name="description" content="Vue.js modal component. Simple, clean with no external dependencies."/>
|
||||||
<meta name="keywords" content="vue, vuejs, modal, dialog, box, modal box, dialog box, vue-modal vuejs-modal.">
|
<meta name="keywords" content="vue, vuejs, modal, dialog, box, modal box, dialog box, vue-modal vuejs-modal.">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
show(resizable = false, adaptive = false, draggable = false) {
|
show(resizable, adaptive, draggable) {
|
||||||
this.resizable = resizable
|
this.resizable = resizable
|
||||||
this.adaptive = adaptive
|
this.adaptive = adaptive
|
||||||
this.draggable = draggable
|
this.draggable = draggable
|
||||||
@@ -131,9 +131,21 @@ button {
|
|||||||
|
|
||||||
color: #4db3ff;
|
color: #4db3ff;
|
||||||
border: 1px solid #4db3ff;
|
border: 1px solid #4db3ff;
|
||||||
|
|
||||||
|
min-width: 90px;
|
||||||
|
|
||||||
|
margin-bottom: 2px;
|
||||||
|
margin-top: 4px;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #20a0ff;
|
color: #20a0ff;
|
||||||
border: 1px solid #20a0ff;
|
border: 1px solid #20a0ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width:600px) {
|
||||||
|
body {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
23
dist/index.js
vendored
23
dist/index.js
vendored
@@ -83,12 +83,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
"use strict";
|
"use strict";
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return inRange; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return inRange; });
|
||||||
var inRange = function inRange(from, to, value) {
|
var inRange = function inRange(from, to, value) {
|
||||||
if (value > to) {
|
|
||||||
return to;
|
|
||||||
}
|
|
||||||
if (value < from) {
|
if (value < from) {
|
||||||
return from;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value > to) {
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -634,6 +636,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
this.visibility.overlay = true;
|
this.visibility.overlay = true;
|
||||||
|
this.adaptWidth();
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
_this.visibility.modal = true;
|
_this.visibility.modal = true;
|
||||||
@@ -708,11 +711,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|||||||
onWindowResize: function onWindowResize() {
|
onWindowResize: function onWindowResize() {
|
||||||
this.window.width = window.innerWidth;
|
this.window.width = window.innerWidth;
|
||||||
this.window.height = window.innerHeight;
|
this.window.height = window.innerHeight;
|
||||||
|
this.adaptWidth();
|
||||||
if (this.adaptive) {
|
|
||||||
this.modal.width = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["a" /* inRange */])(0, this.window.width, this.modal.width);
|
|
||||||
this.modal.height = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["a" /* inRange */])(0, this.window.height, this.modal.height);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
genEventObject: function genEventObject(params) {
|
genEventObject: function genEventObject(params) {
|
||||||
//todo: clean this up (change to ...)
|
//todo: clean this up (change to ...)
|
||||||
@@ -722,6 +721,12 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
}, params || {});
|
}, params || {});
|
||||||
},
|
},
|
||||||
|
adaptWidth: function adaptWidth() {
|
||||||
|
if (this.adaptive) {
|
||||||
|
this.modal.width = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["a" /* inRange */])(0, this.window.width, this.modal.width);
|
||||||
|
this.modal.height = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["a" /* inRange */])(0, this.window.height, this.modal.height);
|
||||||
|
}
|
||||||
|
},
|
||||||
resize: function resize(event) {
|
resize: function resize(event) {
|
||||||
this.modal.width = event.size.width;
|
this.modal.width = event.size.width;
|
||||||
this.modal.height = event.size.height;
|
this.modal.height = event.size.height;
|
||||||
@@ -806,7 +811,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeDraggableListeners: function removeDraggableListeners() {
|
removeDraggableListeners: function removeDraggableListeners() {
|
||||||
console.log('removing draggable handlers');
|
// console.log('removing draggable handlers')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,6 +116,7 @@
|
|||||||
visible (value) {
|
visible (value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.visibility.overlay = true
|
this.visibility.overlay = true
|
||||||
|
this.adaptSize()
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.visibility.modal = true
|
this.visibility.modal = true
|
||||||
@@ -186,11 +187,7 @@
|
|||||||
onWindowResize () {
|
onWindowResize () {
|
||||||
this.window.width = window.innerWidth
|
this.window.width = window.innerWidth
|
||||||
this.window.height = window.innerHeight
|
this.window.height = window.innerHeight
|
||||||
|
this.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)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
genEventObject (params) {
|
genEventObject (params) {
|
||||||
@@ -202,6 +199,13 @@
|
|||||||
}, params || {});
|
}, 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) {
|
resize (event) {
|
||||||
this.modal.width = event.size.width
|
this.modal.width = event.size.width
|
||||||
this.modal.height = event.size.height
|
this.modal.height = event.size.height
|
||||||
@@ -285,7 +289,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeDraggableListeners () {
|
removeDraggableListeners () {
|
||||||
console.log('removing draggable handlers')
|
// console.log('removing draggable handlers')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
export const inRange = (from, to, value) => {
|
export const inRange = (from, to, value) => {
|
||||||
if (value > to) {
|
|
||||||
return to
|
|
||||||
}
|
|
||||||
if (value < from) {
|
if (value < from) {
|
||||||
return from
|
return from
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value > to) {
|
||||||
|
return to
|
||||||
|
}
|
||||||
|
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user