mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(ImagePreview): close event triggered twice (#5411)
This commit is contained in:
parent
93e6c81c49
commit
8dea26db95
@ -1,7 +1,7 @@
|
|||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { emit, inherit } from '../utils/functional';
|
import { emit, inherit } from '../utils/functional';
|
||||||
import { BORDER_TOP, BORDER_BOTTOM } from '../utils/constant';
|
import { BORDER_TOP, BORDER_BOTTOM } from '../utils/constant';
|
||||||
import { PopupMixin } from '../mixins/popup';
|
import { popupMixinProps } from '../mixins/popup';
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
import Popup from '../popup';
|
import Popup from '../popup';
|
||||||
import Loading from '../loading';
|
import Loading from '../loading';
|
||||||
@ -152,7 +152,7 @@ function ActionSheet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActionSheet.props = {
|
ActionSheet.props = {
|
||||||
...PopupMixin.props,
|
...popupMixinProps,
|
||||||
title: String,
|
title: String,
|
||||||
actions: Array,
|
actions: Array,
|
||||||
duration: Number,
|
duration: Number,
|
||||||
|
@ -6,7 +6,7 @@ import Button from '../button';
|
|||||||
const [createComponent, bem, t] = createNamespace('dialog');
|
const [createComponent, bem, t] = createNamespace('dialog');
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
mixins: [PopupMixin],
|
mixins: [PopupMixin()],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
title: String,
|
title: String,
|
||||||
|
@ -18,7 +18,12 @@ function getDistance(touches) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
mixins: [PopupMixin, TouchMixin],
|
mixins: [
|
||||||
|
PopupMixin({
|
||||||
|
skipToggleEvent: true
|
||||||
|
}),
|
||||||
|
TouchMixin
|
||||||
|
],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
className: null,
|
className: null,
|
||||||
@ -83,8 +88,8 @@ export default createComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (scale !== 1) {
|
if (scale !== 1) {
|
||||||
style.transform = `scale3d(${scale}, ${scale}, 1) translate(${this.moveX /
|
style.transform = `scale3d(${scale}, ${scale}, 1) translate(${this
|
||||||
scale}px, ${this.moveY / scale}px)`;
|
.moveX / scale}px, ${this.moveY / scale}px)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
@ -92,8 +97,15 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
value() {
|
value(val) {
|
||||||
this.setActive(this.startPosition);
|
this.setActive(this.startPosition);
|
||||||
|
|
||||||
|
if (!val) {
|
||||||
|
this.$emit('close', {
|
||||||
|
index: this.active,
|
||||||
|
url: this.images[this.active]
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
startPosition(active) {
|
startPosition(active) {
|
||||||
@ -116,14 +128,7 @@ export default createComponent({
|
|||||||
if (deltaTime < 300 && offsetX < 10 && offsetY < 10) {
|
if (deltaTime < 300 && offsetX < 10 && offsetY < 10) {
|
||||||
if (!this.doubleClickTimer) {
|
if (!this.doubleClickTimer) {
|
||||||
this.doubleClickTimer = setTimeout(() => {
|
this.doubleClickTimer = setTimeout(() => {
|
||||||
const index = this.active;
|
|
||||||
|
|
||||||
if (!this.asyncClose) {
|
if (!this.asyncClose) {
|
||||||
this.$emit('close', {
|
|
||||||
index,
|
|
||||||
url: this.images[index]
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$emit('input', false);
|
this.$emit('input', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +253,8 @@ export default createComponent({
|
|||||||
if (this.showIndex) {
|
if (this.showIndex) {
|
||||||
return (
|
return (
|
||||||
<div class={bem('index')}>
|
<div class={bem('index')}>
|
||||||
{this.slots('index') || `${this.active + 1} / ${this.images.length}`}
|
{this.slots('index') ||
|
||||||
|
`${this.active + 1} / ${this.images.length}`}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<demo-section>
|
<demo-section>
|
||||||
<demo-block :title="$t('basicUsage')">
|
<demo-block :title="$t('basicUsage')">
|
||||||
<van-button
|
<van-button type="primary" @click="showImagePreview">
|
||||||
type="primary"
|
|
||||||
@click="showImagePreview"
|
|
||||||
>
|
|
||||||
{{ $t('button1') }}
|
{{ $t('button1') }}
|
||||||
</van-button>
|
</van-button>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="$t('button2')">
|
<demo-block :title="$t('button2')">
|
||||||
<van-button
|
<van-button type="primary" @click="showImagePreview(1)">
|
||||||
type="primary"
|
|
||||||
@click="showImagePreview(1)"
|
|
||||||
>
|
|
||||||
{{ $t('button2') }}
|
{{ $t('button2') }}
|
||||||
</van-button>
|
</van-button>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="$t('button3')">
|
<demo-block :title="$t('button3')">
|
||||||
<van-button
|
<van-button type="primary" @click="showImagePreview(0, 3000)">
|
||||||
type="primary"
|
|
||||||
@click="showImagePreview(0, 1000)"
|
|
||||||
>
|
|
||||||
{{ $t('button3') }}
|
{{ $t('button3') }}
|
||||||
</van-button>
|
</van-button>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="$t('componentCall')">
|
<demo-block :title="$t('componentCall')">
|
||||||
<van-button
|
<van-button type="primary" @click="componentCall">
|
||||||
type="primary"
|
|
||||||
@click="componentCall"
|
|
||||||
>
|
|
||||||
{{ $t('componentCall') }}
|
{{ $t('componentCall') }}
|
||||||
</van-button>
|
</van-button>
|
||||||
<van-image-preview
|
<van-image-preview
|
||||||
@ -112,7 +100,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@import "../../style/var";
|
@import '../../style/var';
|
||||||
|
|
||||||
.demo-image-preview {
|
.demo-image-preview {
|
||||||
background-color: @white;
|
background-color: @white;
|
||||||
|
@ -92,7 +92,7 @@ test('double click', async done => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('onClose option', async done => {
|
test('onClose option', () => {
|
||||||
const onClose = jest.fn();
|
const onClose = jest.fn();
|
||||||
const instance = ImagePreview({
|
const instance = ImagePreview({
|
||||||
images,
|
images,
|
||||||
@ -100,37 +100,10 @@ test('onClose option', async done => {
|
|||||||
onClose
|
onClose
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.$emit('input', true);
|
|
||||||
expect(onClose).toHaveBeenCalledTimes(0);
|
|
||||||
|
|
||||||
await later(300);
|
|
||||||
|
|
||||||
const wrapper = document.querySelector('.van-image-preview');
|
|
||||||
const swipe = wrapper.querySelector('.van-swipe__track');
|
|
||||||
triggerDrag(swipe, 0, 0);
|
|
||||||
expect(onClose).toHaveBeenCalledTimes(1);
|
|
||||||
expect(onClose).toHaveBeenCalledWith({ index: 0, url: 'https://img.yzcdn.cn/1.png' });
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('onClose should only trigger once', async done => {
|
|
||||||
const onClose = jest.fn();
|
|
||||||
const instance = ImagePreview({
|
|
||||||
images,
|
|
||||||
startPostion: 1,
|
|
||||||
onClose
|
|
||||||
});
|
|
||||||
|
|
||||||
ImagePreview({
|
|
||||||
images,
|
|
||||||
startPostion: 1,
|
|
||||||
onClose
|
|
||||||
});
|
|
||||||
|
|
||||||
instance.close();
|
instance.close();
|
||||||
|
|
||||||
expect(onClose).toHaveBeenCalledTimes(1);
|
expect(onClose).toHaveBeenCalledTimes(1);
|
||||||
done();
|
expect(onClose).toHaveBeenCalledWith({ index: 0, url: 'https://img.yzcdn.cn/1.png' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('onChange option', async done => {
|
test('onChange option', async done => {
|
||||||
|
@ -6,190 +6,197 @@ import { on, off, preventDefault } from '../../utils/dom/event';
|
|||||||
import { openOverlay, closeOverlay, updateOverlay } from './overlay';
|
import { openOverlay, closeOverlay, updateOverlay } from './overlay';
|
||||||
import { getScrollEventTarget } from '../../utils/dom/scroll';
|
import { getScrollEventTarget } from '../../utils/dom/scroll';
|
||||||
|
|
||||||
export const PopupMixin = {
|
export const popupMixinProps = {
|
||||||
mixins: [
|
// whether to show popup
|
||||||
TouchMixin,
|
value: Boolean,
|
||||||
CloseOnPopstateMixin,
|
// whether to show overlay
|
||||||
PortalMixin({
|
overlay: Boolean,
|
||||||
afterPortal() {
|
// overlay custom style
|
||||||
if (this.overlay) {
|
overlayStyle: Object,
|
||||||
updateOverlay();
|
// overlay custom class name
|
||||||
}
|
overlayClass: String,
|
||||||
}
|
// whether to close popup when click overlay
|
||||||
})
|
closeOnClickOverlay: Boolean,
|
||||||
],
|
// z-index
|
||||||
|
zIndex: [Number, String],
|
||||||
props: {
|
// prevent body scroll
|
||||||
// whether to show popup
|
lockScroll: {
|
||||||
value: Boolean,
|
type: Boolean,
|
||||||
// whether to show overlay
|
default: true
|
||||||
overlay: Boolean,
|
|
||||||
// overlay custom style
|
|
||||||
overlayStyle: Object,
|
|
||||||
// overlay custom class name
|
|
||||||
overlayClass: String,
|
|
||||||
// whether to close popup when click overlay
|
|
||||||
closeOnClickOverlay: Boolean,
|
|
||||||
// z-index
|
|
||||||
zIndex: [Number, String],
|
|
||||||
// prevent body scroll
|
|
||||||
lockScroll: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
// whether to lazy render
|
|
||||||
lazyRender: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
// whether to lazy render
|
||||||
data() {
|
lazyRender: {
|
||||||
return {
|
type: Boolean,
|
||||||
inited: this.value
|
default: true
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
shouldRender() {
|
|
||||||
return this.inited || !this.lazyRender;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
value(val) {
|
|
||||||
const type = val ? 'open' : 'close';
|
|
||||||
this.inited = this.inited || this.value;
|
|
||||||
this[type]();
|
|
||||||
this.$emit(type);
|
|
||||||
},
|
|
||||||
|
|
||||||
overlay: 'renderOverlay'
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
if (this.value) {
|
|
||||||
this.open();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
activated() {
|
|
||||||
if (this.shouldReopen) {
|
|
||||||
this.$emit('input', true);
|
|
||||||
this.shouldReopen = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
beforeDestroy() {
|
|
||||||
this.close();
|
|
||||||
|
|
||||||
if (this.getContainer && this.$parent && this.$parent.$el) {
|
|
||||||
this.$parent.$el.appendChild(this.$el);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
deactivated() {
|
|
||||||
if (this.value) {
|
|
||||||
this.close();
|
|
||||||
this.shouldReopen = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
open() {
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (this.$isServer || this.opened) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cover default zIndex
|
|
||||||
if (this.zIndex !== undefined) {
|
|
||||||
context.zIndex = this.zIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.opened = true;
|
|
||||||
this.renderOverlay();
|
|
||||||
|
|
||||||
if (this.lockScroll) {
|
|
||||||
on(document, 'touchstart', this.touchStart);
|
|
||||||
on(document, 'touchmove', this.onTouchMove);
|
|
||||||
|
|
||||||
if (!context.lockCount) {
|
|
||||||
document.body.classList.add('van-overflow-hidden');
|
|
||||||
}
|
|
||||||
context.lockCount++;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
close() {
|
|
||||||
if (!this.opened) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.lockScroll) {
|
|
||||||
context.lockCount--;
|
|
||||||
off(document, 'touchstart', this.touchStart);
|
|
||||||
off(document, 'touchmove', this.onTouchMove);
|
|
||||||
|
|
||||||
if (!context.lockCount) {
|
|
||||||
document.body.classList.remove('van-overflow-hidden');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.opened = false;
|
|
||||||
closeOverlay(this);
|
|
||||||
this.$emit('input', false);
|
|
||||||
},
|
|
||||||
|
|
||||||
onTouchMove(event) {
|
|
||||||
this.touchMove(event);
|
|
||||||
const direction = this.deltaY > 0 ? '10' : '01';
|
|
||||||
const el = getScrollEventTarget(event.target, this.$el);
|
|
||||||
const { scrollHeight, offsetHeight, scrollTop } = el;
|
|
||||||
let status = '11';
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (scrollTop === 0) {
|
|
||||||
status = offsetHeight >= scrollHeight ? '00' : '01';
|
|
||||||
} else if (scrollTop + offsetHeight >= scrollHeight) {
|
|
||||||
status = '10';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (
|
|
||||||
status !== '11' &&
|
|
||||||
this.direction === 'vertical' &&
|
|
||||||
!(parseInt(status, 2) & parseInt(direction, 2))
|
|
||||||
) {
|
|
||||||
preventDefault(event, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
renderOverlay() {
|
|
||||||
if (this.$isServer || !this.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.updateZIndex(this.overlay ? 1 : 0);
|
|
||||||
|
|
||||||
if (this.overlay) {
|
|
||||||
openOverlay(this, {
|
|
||||||
zIndex: context.zIndex++,
|
|
||||||
duration: this.duration,
|
|
||||||
className: this.overlayClass,
|
|
||||||
customStyle: this.overlayStyle
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
closeOverlay(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
updateZIndex(value = 0) {
|
|
||||||
this.$el.style.zIndex = ++context.zIndex + value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function PopupMixin(options = {}) {
|
||||||
|
return {
|
||||||
|
mixins: [
|
||||||
|
TouchMixin,
|
||||||
|
CloseOnPopstateMixin,
|
||||||
|
PortalMixin({
|
||||||
|
afterPortal() {
|
||||||
|
if (this.overlay) {
|
||||||
|
updateOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
|
||||||
|
props: popupMixinProps,
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
inited: this.value
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
shouldRender() {
|
||||||
|
return this.inited || !this.lazyRender;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
value(val) {
|
||||||
|
const type = val ? 'open' : 'close';
|
||||||
|
this.inited = this.inited || this.value;
|
||||||
|
this[type]();
|
||||||
|
|
||||||
|
if (!options.skipToggleEvent) {
|
||||||
|
this.$emit(type);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
overlay: 'renderOverlay'
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
if (this.value) {
|
||||||
|
this.open();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
activated() {
|
||||||
|
if (this.shouldReopen) {
|
||||||
|
this.$emit('input', true);
|
||||||
|
this.shouldReopen = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
this.close();
|
||||||
|
|
||||||
|
if (this.getContainer && this.$parent && this.$parent.$el) {
|
||||||
|
this.$parent.$el.appendChild(this.$el);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
deactivated() {
|
||||||
|
if (this.value) {
|
||||||
|
this.close();
|
||||||
|
this.shouldReopen = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
open() {
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (this.$isServer || this.opened) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cover default zIndex
|
||||||
|
if (this.zIndex !== undefined) {
|
||||||
|
context.zIndex = this.zIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opened = true;
|
||||||
|
this.renderOverlay();
|
||||||
|
|
||||||
|
if (this.lockScroll) {
|
||||||
|
on(document, 'touchstart', this.touchStart);
|
||||||
|
on(document, 'touchmove', this.onTouchMove);
|
||||||
|
|
||||||
|
if (!context.lockCount) {
|
||||||
|
document.body.classList.add('van-overflow-hidden');
|
||||||
|
}
|
||||||
|
context.lockCount++;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
close() {
|
||||||
|
if (!this.opened) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.lockScroll) {
|
||||||
|
context.lockCount--;
|
||||||
|
off(document, 'touchstart', this.touchStart);
|
||||||
|
off(document, 'touchmove', this.onTouchMove);
|
||||||
|
|
||||||
|
if (!context.lockCount) {
|
||||||
|
document.body.classList.remove('van-overflow-hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opened = false;
|
||||||
|
closeOverlay(this);
|
||||||
|
this.$emit('input', false);
|
||||||
|
},
|
||||||
|
|
||||||
|
onTouchMove(event) {
|
||||||
|
this.touchMove(event);
|
||||||
|
const direction = this.deltaY > 0 ? '10' : '01';
|
||||||
|
const el = getScrollEventTarget(event.target, this.$el);
|
||||||
|
const { scrollHeight, offsetHeight, scrollTop } = el;
|
||||||
|
let status = '11';
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (scrollTop === 0) {
|
||||||
|
status = offsetHeight >= scrollHeight ? '00' : '01';
|
||||||
|
} else if (scrollTop + offsetHeight >= scrollHeight) {
|
||||||
|
status = '10';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
|
if (
|
||||||
|
status !== '11' &&
|
||||||
|
this.direction === 'vertical' &&
|
||||||
|
!(parseInt(status, 2) & parseInt(direction, 2))
|
||||||
|
) {
|
||||||
|
preventDefault(event, true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
renderOverlay() {
|
||||||
|
if (this.$isServer || !this.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.updateZIndex(this.overlay ? 1 : 0);
|
||||||
|
|
||||||
|
if (this.overlay) {
|
||||||
|
openOverlay(this, {
|
||||||
|
zIndex: context.zIndex++,
|
||||||
|
duration: this.duration,
|
||||||
|
className: this.overlayClass,
|
||||||
|
customStyle: this.overlayStyle
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
closeOverlay(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateZIndex(value = 0) {
|
||||||
|
this.$el.style.zIndex = ++context.zIndex + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -31,13 +31,17 @@ function onClickOverlay(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mountOverlay() {
|
||||||
|
overlay = mount(Overlay, {
|
||||||
|
on: {
|
||||||
|
click: onClickOverlay
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function updateOverlay(): void {
|
export function updateOverlay(): void {
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
overlay = mount(Overlay, {
|
mountOverlay();
|
||||||
on: {
|
|
||||||
click: onClickOverlay
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.top) {
|
if (context.top) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { WHITE } from '../utils/constant';
|
import { WHITE } from '../utils/constant';
|
||||||
import { inherit } from '../utils/functional';
|
import { inherit } from '../utils/functional';
|
||||||
import { PopupMixin } from '../mixins/popup';
|
import { popupMixinProps } from '../mixins/popup';
|
||||||
import Popup from '../popup';
|
import Popup from '../popup';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
@ -48,7 +48,7 @@ function Notify(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Notify.props = {
|
Notify.props = {
|
||||||
...PopupMixin.props,
|
...popupMixinProps,
|
||||||
background: String,
|
background: String,
|
||||||
className: null as any,
|
className: null as any,
|
||||||
message: [Number, String],
|
message: [Number, String],
|
||||||
|
@ -5,7 +5,7 @@ import Icon from '../icon';
|
|||||||
const [createComponent, bem] = createNamespace('popup');
|
const [createComponent, bem] = createNamespace('popup');
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
mixins: [PopupMixin],
|
mixins: [PopupMixin()],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
round: Boolean,
|
round: Boolean,
|
||||||
|
@ -7,7 +7,7 @@ import Loading from '../loading';
|
|||||||
const [createComponent, bem] = createNamespace('toast');
|
const [createComponent, bem] = createNamespace('toast');
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
mixins: [PopupMixin],
|
mixins: [PopupMixin()],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
icon: String,
|
icon: String,
|
||||||
|
2
types/image-preview.d.ts
vendored
2
types/image-preview.d.ts
vendored
@ -19,7 +19,9 @@ export type ImagePreviewOptions = string[] | {
|
|||||||
|
|
||||||
export class VanImagePreview extends VanPopupMixin {
|
export class VanImagePreview extends VanPopupMixin {
|
||||||
images: string[];
|
images: string[];
|
||||||
|
|
||||||
showIndex: boolean;
|
showIndex: boolean;
|
||||||
|
|
||||||
startPosition: number;
|
startPosition: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user