UNPKG

vimo-dt

Version:

A Vue2.x UI Project For Mobile & HyBrid

107 lines (91 loc) 2.7 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _urlChange = require('./url-change'); var _urlChange2 = _interopRequireDefault(_urlChange); var _animateExtend = require('./animate-extend'); var _animateExtend2 = _interopRequireDefault(_animateExtend); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = { extends: _animateExtend2.default, data: function data() { return { unReg: null, $_dismissOnPageChange: true, $_recordInHistory: false }; }, props: { dismissOnPageChange: { type: Boolean, default: true }, recordInHistory: { type: Boolean, default: false }, scrollControl: { type: Boolean, default: true } }, methods: { beforePresent: function beforePresent() {}, beforeDismiss: function beforeDismiss(data) {} }, created: function created() { var _this = this; if (this.scrollControl) { this.$app && this.$app.$_disableScroll && this.$app.$_disableScroll(); } this.$app && this.$app.$_addChild && this.$app.$_addChild(this); this.$_dismissOnPageChange = this.dismissOnPageChange; this.$_recordInHistory = this.recordInHistory; if (this.$_recordInHistory) { this.$_dismissOnPageChange = true; window.history.pushState({ id: new Date().getTime(), name: '' + this._uid }, '', ''); } if (this.$_dismissOnPageChange) { this.unReg = (0, _urlChange2.default)(function () { _this.$_recordInHistory = false; _this.dismiss(); }); } this.$on('animate:beforeEnter', function () { _this.$emit('popup:beforeEnter'); }); this.$on('animate:afterEnter', function () { _this.$emit('popup:afterEnter'); }); this.$on('animate:beforeLeave', function () { _this.$emit('popup:beforeLeave'); }); this.$on('animate:afterLeave', function () { _this.$emit('popup:afterLeave'); _this.$destroy(); }); this.$on('animate:present', function () { _this.$emit('popup:present'); _this.beforePresent(); }); this.$on('animate:dismiss', function (data) { _this.$emit('popup:dismiss'); _this.unReg && _this.unReg(); if (_this.$_recordInHistory) { window.history.back(); } _this.beforeDismiss(data); }); }, destroyed: function destroyed() { if (this.scrollControl) { this.$app && this.$app.$_enableScroll && this.$app.$_enableScroll(); } this.$app && this.$app.$_removeChild && this.$app.$_removeChild(this); this.$el && this.$el.remove(); } };