mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: remove closeOnPopstate mixin
This commit is contained in:
parent
a4743fa648
commit
d783fcf2f4
@ -1,44 +0,0 @@
|
|||||||
import { on, off } from '../utils/dom/event';
|
|
||||||
import { BindEventMixin } from './bind-event';
|
|
||||||
|
|
||||||
export const CloseOnPopstateMixin = {
|
|
||||||
mixins: [
|
|
||||||
BindEventMixin(function (bind, isBind) {
|
|
||||||
this.handlePopstate(isBind && this.closeOnPopstate);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
|
|
||||||
props: {
|
|
||||||
closeOnPopstate: Boolean,
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
bindStatus: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
closeOnPopstate(val) {
|
|
||||||
this.handlePopstate(val);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
handlePopstate(bind) {
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (this.$isServer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.bindStatus !== bind) {
|
|
||||||
this.bindStatus = bind;
|
|
||||||
const action = bind ? on : off;
|
|
||||||
action(window, 'popstate', () => {
|
|
||||||
this.close();
|
|
||||||
this.shouldReopen = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
@ -13,9 +13,9 @@ import {
|
|||||||
import { createNamespace, isDef } from '../utils';
|
import { createNamespace, isDef } from '../utils';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
|
import { useEventListener } from '@vant/use';
|
||||||
import { useLockScroll } from '../composition/use-lock-scroll';
|
import { useLockScroll } from '../composition/use-lock-scroll';
|
||||||
import { useLazyRender } from '../composition/use-lazy-render';
|
import { useLazyRender } from '../composition/use-lazy-render';
|
||||||
import { CloseOnPopstateMixin } from '../mixins/close-on-popstate';
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
@ -68,8 +68,6 @@ export const popupSharedProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
mixins: [CloseOnPopstateMixin],
|
|
||||||
|
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@ -77,6 +75,7 @@ export default createComponent({
|
|||||||
round: Boolean,
|
round: Boolean,
|
||||||
closeable: Boolean,
|
closeable: Boolean,
|
||||||
transition: String,
|
transition: String,
|
||||||
|
closeOnPopstate: Boolean,
|
||||||
safeAreaInsetBottom: Boolean,
|
safeAreaInsetBottom: Boolean,
|
||||||
position: {
|
position: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -237,6 +236,13 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEventListener('popstate', () => {
|
||||||
|
if (props.closeOnPopstate) {
|
||||||
|
close();
|
||||||
|
shouldReopen = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.show) {
|
if (props.show) {
|
||||||
open();
|
open();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user