From 2573c3e2c8d90bbabea8dd82f4cc706dce534520 Mon Sep 17 00:00:00 2001 From: DaxChen Date: Fri, 6 Oct 2017 16:24:07 +0800 Subject: [PATCH] build --- dist/index.js | 77 ++++++++++++++++++++++++++++++----------------- dist/ssr.index.js | 77 ++++++++++++++++++++++++++++++----------------- 2 files changed, 98 insertions(+), 56 deletions(-) diff --git a/dist/index.js b/dist/index.js index 86992ad..bd3d7d4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -207,7 +207,7 @@ }, function(module, exports, __webpack_require__) { __webpack_require__(18); var Component = __webpack_require__(1)(__webpack_require__(7), __webpack_require__(15), null, null); - Component.options.__file = "/Users/yev/Projects/vue/vue-js-modal/src/Dialog.vue", + Component.options.__file = "/Users/dd/code/sandbox/vue-js-modal/src/Dialog.vue", Component.esModule && Object.keys(Component.esModule).some(function(key) { return "default" !== key && "__esModule" !== key; }) && console.error("named exports are not supported in *.vue files."), Component.options.functional && console.error("[vue-loader] Dialog.vue: functional components are not supported with templates, they should use render functions."), @@ -215,7 +215,7 @@ }, function(module, exports, __webpack_require__) { __webpack_require__(19); var Component = __webpack_require__(1)(__webpack_require__(8), __webpack_require__(16), null, null); - Component.options.__file = "/Users/yev/Projects/vue/vue-js-modal/src/Modal.vue", + Component.options.__file = "/Users/dd/code/sandbox/vue-js-modal/src/Modal.vue", Component.esModule && Object.keys(Component.esModule).some(function(key) { return "default" !== key && "__esModule" !== key; }) && console.error("named exports are not supported in *.vue files."), Component.options.functional && console.error("[vue-loader] Modal.vue: functional components are not supported with templates, they should use render functions."), @@ -282,7 +282,11 @@ Object.defineProperty(exports, "__esModule", { value: !0 }); - var _index = __webpack_require__(3), _index2 = _interopRequireDefault(_index), _Resizer = __webpack_require__(14), _Resizer2 = _interopRequireDefault(_Resizer), _util = __webpack_require__(4), _parser = __webpack_require__(10), _parser2 = _interopRequireDefault(_parser); + var _index = __webpack_require__(3), _index2 = _interopRequireDefault(_index), _Resizer = __webpack_require__(14), _Resizer2 = _interopRequireDefault(_Resizer), _util = __webpack_require__(4), _parser = __webpack_require__(10), _parser2 = _interopRequireDefault(_parser), MutationObserver = function() { + for (var prefixes = [ "", "WebKit", "Moz", "O", "Ms" ], i = 0; i < prefixes.length; i++) if (prefixes[i] + "MutationObserver" in window) return console.log("got MutationObserver:", prefixes[i] + "MutationObserver"), + window[prefixes[i] + "MutationObserver"]; + return !1; + }(); exports.default = { name: "VueJsModal", props: { @@ -395,12 +399,14 @@ width: 0, widthType: "px", height: 0, - heightType: "px" + heightType: "px", + renderedHeight: 0 }, window: { width: 0, height: 0 - } + }, + mutationObserver: null }; }, watch: { @@ -408,11 +414,11 @@ var _this = this; value ? (this.visibility.overlay = !0, setTimeout(function() { _this.visibility.modal = !0, _this.$nextTick(function() { - _this.addDraggableListeners(); + _this.addDraggableListeners(), _this.callAfterEvent(!0); }); }, this.delay)) : (this.visibility.modal = !1, setTimeout(function() { _this.visibility.overlay = !1, _this.$nextTick(function() { - _this.removeDraggableListeners(); + _this.removeDraggableListeners(), _this.callAfterEvent(!1); }); }, this.delay)); } @@ -425,7 +431,10 @@ _index2.default.event.$on("toggle", function(name, state, params) { name === _this2.name && (void 0 === state && (state = !_this2.visible), _this2.toggle(state, params)); }), window.addEventListener("resize", this.onWindowResize), this.onWindowResize(), - this.scrollable && !this.isAutoHeight && console.warn('Modal "' + this.name + '" has scrollable flag set to true but height is not "auto" (' + this.height + ")"); + this.scrollable && !this.isAutoHeight && console.warn('Modal "' + this.name + '" has scrollable flag set to true but height is not "auto" (' + this.height + ")"), + this.isAutoHeight && MutationObserver && (this.mutationObserver = new MutationObserver(function(mutations) { + _this2.updateRenderedHeight(); + })); }, beforeDestroy: function() { window.removeEventListener("resize", this.onWindowResize); @@ -435,10 +444,10 @@ return "auto" === this.modal.heightType; }, position: function() { - var window = this.window, shift = this.shift, pivotX = this.pivotX, pivotY = this.pivotY, trueModalWidth = this.trueModalWidth, trueModalHeight = this.trueModalHeight, maxLeft = window.width - trueModalWidth, maxTop = window.height - trueModalHeight, minTop = this.scrollable ? Number.NEGATIVE_INFINITY : 0, left = shift.left + pivotX * maxLeft, top = shift.top + pivotY * maxTop; + var window = this.window, shift = this.shift, pivotX = this.pivotX, pivotY = this.pivotY, trueModalWidth = this.trueModalWidth, trueModalHeight = this.trueModalHeight, maxLeft = window.width - trueModalWidth, maxTop = window.height - trueModalHeight, left = shift.left + pivotX * maxLeft, top = shift.top + pivotY * maxTop; return { left: (0, _util.inRange)(0, maxLeft, left), - top: (0, _util.inRange)(minTop, maxTop, top) + top: (0, _util.inRange)(0, maxTop, top) }; }, trueModalWidth: function() { @@ -447,7 +456,7 @@ }, trueModalHeight: function() { var window = this.window, modal = this.modal, isAutoHeight = this.isAutoHeight, adaptive = this.adaptive, value = "%" === modal.heightType ? window.height / 100 * modal.height : modal.height; - return isAutoHeight ? 0 : adaptive ? (0, _util.inRange)(this.minHeight, this.window.height, value) : value; + return isAutoHeight ? this.modal.renderedHeight : adaptive ? (0, _util.inRange)(this.minHeight, this.window.height, value) : value; }, overlayClass: function() { return { @@ -495,10 +504,9 @@ this.$emit("resize", resizeEvent); }, toggle: function(state, params) { - var reset = this.reset, scrollable = this.scrollable, visible = this.visible, beforeEventName = visible ? "before-close" : "before-open", afterEventName = visible ? "closed" : "opened"; - "before-open" === beforeEventName && (reset && (this.setInitialSize(), this.shift.left = 0, - this.shift.top = 0), scrollable && document.body.classList.add("v--modal-block-scroll")), - "before-close" === beforeEventName && scrollable && document.body.classList.remove("v--modal-block-scroll"); + var reset = this.reset, scrollable = this.scrollable, visible = this.visible, beforeEventName = visible ? "before-close" : "before-open"; + "before-open" === beforeEventName ? (reset && (this.setInitialSize(), this.shift.left = 0, + this.shift.top = 0), scrollable && document.body.classList.add("v--modal-block-scroll")) : scrollable && document.body.classList.remove("v--modal-block-scroll"); var stopEventExecution = !1, stop = function() { stopEventExecution = !0; }, beforeEvent = this.genEventObject({ @@ -506,13 +514,7 @@ state: state, params: params }); - if (this.$emit(beforeEventName, beforeEvent), !stopEventExecution) { - var afterEvent = this.genEventObject({ - state: state, - params: params - }); - this.visible = state, this.$emit(afterEventName, afterEvent); - } + this.$emit(beforeEventName, beforeEvent), stopEventExecution || (this.visible = state); }, getDraggableElement: function() { var selector = "string" != typeof this.draggable ? ".v--modal-box" : this.draggable; @@ -552,7 +554,26 @@ } } }, - removeDraggableListeners: function() {} + removeDraggableListeners: function() {}, + callAfterEvent: function(state) { + state ? this.observe() : this.disconnectObserver(); + var afterEventName = state ? "opened" : "closed", afterEvent = this.genEventObject({ + state: state + }); + this.$emit(afterEventName, afterEvent), state && this.isAutoHeight && this.updateRenderedHeight(); + }, + updateRenderedHeight: function() { + this.modal.renderedHeight = this.$refs.modal.getBoundingClientRect().height; + }, + observe: function() { + this.mutationObserver && this.mutationObserver.observe(this.$refs.modal, { + childList: !0, + subtree: !0 + }); + }, + disconnectObserver: function() { + this.mutationObserver && this.mutationObserver.disconnect(); + } } }; }, function(module, exports, __webpack_require__) { @@ -685,13 +706,13 @@ sourceRoot: "webpack://" } ]); }, function(module, exports, __webpack_require__) { - exports = module.exports = __webpack_require__(0)(), exports.push([ module.i, "\n.v--modal-block-scroll {\n overflow: hidden;\n}\n.v--modal-overlay {\n position: fixed;\n box-sizing: border-box;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0, 0, 0, 0.2);\n z-index: 999;\n opacity: 1;\n}\n.v--modal-overlay.scrollable {\n height: 100%;\n min-height: 100vh;\n overflow-y: auto;\n padding-bottom: 10px;\n}\n.v--modal-overlay .v--modal-box {\n position: relative;\n overflow: hidden;\n box-sizing: border-box;\n}\n.v--modal-overlay.scrollable .v--modal-box {\n margin-bottom: 10px;\n}\n.v--modal {\n background-color: white;\n text-align: left;\n border-radius: 3px;\n box-shadow: 0 20px 60px -2px rgba(27, 33, 58, .4);\n padding: 0;\n}\n.v--modal.v--modal-fullscreen {\n width: 100vw;\n height: 100vh;\n margin: 0;\n left: 0;\n top: 0;\n}\n.v--modal-top-right {\n display: block;\n position: absolute;\n right: 0;\n top: 0;\n}\n.overlay-fade-enter-active, .overlay-fade-leave-active {\n transition: all 0.2s;\n}\n.overlay-fade-enter, .overlay-fade-leave-active {\n opacity: 0;\n}\n.nice-modal-fade-enter-active, .nice-modal-fade-leave-active {\n transition: all 0.4s;\n}\n.nice-modal-fade-enter, .nice-modal-fade-leave-active {\n opacity: 0;\n transform: translateY(-20px);\n}\n", "", { + exports = module.exports = __webpack_require__(0)(), exports.push([ module.i, "\n.v--modal-block-scroll {\n overflow: hidden;\n}\n.v--modal-overlay {\n position: fixed;\n box-sizing: border-box;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0, 0, 0, 0.2);\n z-index: 999;\n opacity: 1;\n}\n.v--modal-overlay.scrollable {\n height: 100%;\n min-height: 100vh;\n overflow-y: auto;\n padding-bottom: 10px;\n}\n.v--modal-overlay .v--modal-box {\n position: relative;\n overflow: hidden;\n box-sizing: border-box;\n}\n.v--modal-overlay.scrollable .v--modal-box {\n margin-bottom: 10px;\n transition: top 0.2s ease;\n}\n.v--modal {\n background-color: white;\n text-align: left;\n border-radius: 3px;\n box-shadow: 0 20px 60px -2px rgba(27, 33, 58, .4);\n padding: 0;\n}\n.v--modal.v--modal-fullscreen {\n width: 100vw;\n height: 100vh;\n margin: 0;\n left: 0;\n top: 0;\n}\n.v--modal-top-right {\n display: block;\n position: absolute;\n right: 0;\n top: 0;\n}\n.overlay-fade-enter-active, .overlay-fade-leave-active {\n transition: all 0.2s;\n}\n.overlay-fade-enter, .overlay-fade-leave-active {\n opacity: 0;\n}\n.nice-modal-fade-enter-active, .nice-modal-fade-leave-active {\n transition: all 0.4s;\n}\n.nice-modal-fade-enter, .nice-modal-fade-leave-active {\n opacity: 0;\n transform: translateY(-20px);\n}\n", "", { version: 3, - sources: [ "/./src/Modal.vue?2cbada4c" ], + sources: [ "/./src/Modal.vue?d2188c9c" ], names: [], - mappings: ";AA4fA;EACA,iBAAA;CACA;AAEA;EACA,gBAAA;EACA,uBAAA;EACA,QAAA;EACA,OAAA;EACA,aAAA;EACA,cAAA;EACA,+BAAA;EACA,aAAA;EACA,WAAA;CACA;AAEA;EACA,aAAA;EACA,kBAAA;EACA,iBAAA;EACA,qBAAA;CACA;AAEA;EACA,mBAAA;EACA,iBAAA;EACA,uBAAA;CACA;AAEA;EACA,oBAAA;CACA;AAEA;EACA,wBAAA;EACA,iBAAA;EACA,mBAAA;EACA,kDAAA;EACA,WAAA;CACA;AAEA;EACA,aAAA;EACA,cAAA;EACA,UAAA;EACA,QAAA;EACA,OAAA;CACA;AAEA;EACA,eAAA;EACA,mBAAA;EACA,SAAA;EACA,OAAA;CACA;AAEA;EACA,qBAAA;CACA;AAEA;EACA,WAAA;CACA;AAEA;EACA,qBAAA;CACA;AAEA;EACA,WAAA;EACA,6BAAA;CACA", + mappings: ";AAglBA;EACA,iBAAA;CACA;AAEA;EACA,gBAAA;EACA,uBAAA;EACA,QAAA;EACA,OAAA;EACA,aAAA;EACA,cAAA;EACA,+BAAA;EACA,aAAA;EACA,WAAA;CACA;AAEA;EACA,aAAA;EACA,kBAAA;EACA,iBAAA;EACA,qBAAA;CACA;AAEA;EACA,mBAAA;EACA,iBAAA;EACA,uBAAA;CACA;AAEA;EACA,oBAAA;EACA,0BAAA;CACA;AAEA;EACA,wBAAA;EACA,iBAAA;EACA,mBAAA;EACA,kDAAA;EACA,WAAA;CACA;AAEA;EACA,aAAA;EACA,cAAA;EACA,UAAA;EACA,QAAA;EACA,OAAA;CACA;AAEA;EACA,eAAA;EACA,mBAAA;EACA,SAAA;EACA,OAAA;CACA;AAEA;EACA,qBAAA;CACA;AAEA;EACA,WAAA;CACA;AAEA;EACA,qBAAA;CACA;AAEA;EACA,WAAA;EACA,6BAAA;CACA", file: "Modal.vue", - sourcesContent: [ "\n