first
This commit is contained in:
46
node_modules/vant/lib/mixins/close-on-popstate.js
generated
vendored
Normal file
46
node_modules/vant/lib/mixins/close-on-popstate.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.CloseOnPopstateMixin = void 0;
|
||||
|
||||
var _event = require("../utils/dom/event");
|
||||
|
||||
var _bindEvent = require("./bind-event");
|
||||
|
||||
var CloseOnPopstateMixin = {
|
||||
mixins: [(0, _bindEvent.BindEventMixin)(function (bind, isBind) {
|
||||
this.handlePopstate(isBind && this.closeOnPopstate);
|
||||
})],
|
||||
props: {
|
||||
closeOnPopstate: Boolean
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
bindStatus: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
closeOnPopstate: function closeOnPopstate(val) {
|
||||
this.handlePopstate(val);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onPopstate: function onPopstate() {
|
||||
this.close();
|
||||
this.shouldReopen = false;
|
||||
},
|
||||
handlePopstate: function handlePopstate(bind) {
|
||||
/* istanbul ignore if */
|
||||
if (this.$isServer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.bindStatus !== bind) {
|
||||
this.bindStatus = bind;
|
||||
var action = bind ? _event.on : _event.off;
|
||||
action(window, 'popstate', this.onPopstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.CloseOnPopstateMixin = CloseOnPopstateMixin;
|
Reference in New Issue
Block a user