chore: add trailingComma
This commit is contained in:
@@ -20,9 +20,9 @@ function getDistance(touches) {
|
||||
export default createComponent({
|
||||
mixins: [
|
||||
PopupMixin({
|
||||
skipToggleEvent: true
|
||||
skipToggleEvent: true,
|
||||
}),
|
||||
TouchMixin
|
||||
TouchMixin,
|
||||
],
|
||||
|
||||
props: {
|
||||
@@ -32,40 +32,40 @@ export default createComponent({
|
||||
showIndicators: Boolean,
|
||||
images: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
default: () => [],
|
||||
},
|
||||
loop: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: true,
|
||||
},
|
||||
swipeDuration: {
|
||||
type: Number,
|
||||
default: 500
|
||||
default: 500,
|
||||
},
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: true,
|
||||
},
|
||||
showIndex: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: true,
|
||||
},
|
||||
startPosition: {
|
||||
type: Number,
|
||||
default: 0
|
||||
default: 0,
|
||||
},
|
||||
minZoom: {
|
||||
type: Number,
|
||||
default: 1 / 3
|
||||
default: 1 / 3,
|
||||
},
|
||||
maxZoom: {
|
||||
type: Number,
|
||||
default: 3
|
||||
default: 3,
|
||||
},
|
||||
overlayClass: {
|
||||
type: String,
|
||||
default: bem('overlay')
|
||||
}
|
||||
default: bem('overlay'),
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -76,7 +76,7 @@ export default createComponent({
|
||||
active: 0,
|
||||
moving: false,
|
||||
zooming: false,
|
||||
doubleClickTimer: null
|
||||
doubleClickTimer: null,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -84,7 +84,7 @@ export default createComponent({
|
||||
imageStyle() {
|
||||
const { scale } = this;
|
||||
const style = {
|
||||
transitionDuration: this.zooming || this.moving ? '0s' : '.3s'
|
||||
transitionDuration: this.zooming || this.moving ? '0s' : '.3s',
|
||||
};
|
||||
|
||||
if (scale !== 1) {
|
||||
@@ -93,7 +93,7 @@ export default createComponent({
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
@@ -106,7 +106,7 @@ export default createComponent({
|
||||
} else {
|
||||
this.$emit('close', {
|
||||
index: this.active,
|
||||
url: this.images[this.active]
|
||||
url: this.images[this.active],
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -127,8 +127,8 @@ export default createComponent({
|
||||
});
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -288,7 +288,7 @@ export default createComponent({
|
||||
|
||||
genImages() {
|
||||
const imageSlots = {
|
||||
loading: () => <Loading type="spinner" />
|
||||
loading: () => <Loading type="spinner" />,
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -320,7 +320,7 @@ export default createComponent({
|
||||
))}
|
||||
</Swipe>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
render() {
|
||||
@@ -337,5 +337,5 @@ export default createComponent({
|
||||
</div>
|
||||
</transition>
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ const images = [
|
||||
'https://img.yzcdn.cn/vant/apple-1.jpg',
|
||||
'https://img.yzcdn.cn/vant/apple-2.jpg',
|
||||
'https://img.yzcdn.cn/vant/apple-3.jpg',
|
||||
'https://img.yzcdn.cn/vant/apple-4.jpg'
|
||||
'https://img.yzcdn.cn/vant/apple-4.jpg',
|
||||
];
|
||||
|
||||
export default {
|
||||
@@ -51,22 +51,22 @@ export default {
|
||||
button2: '指定初始位置',
|
||||
button3: '异步关闭',
|
||||
componentCall: '组件调用',
|
||||
index: index => `第${index + 1}页`
|
||||
index: index => `第${index + 1}页`,
|
||||
},
|
||||
'en-US': {
|
||||
button1: 'Show Images',
|
||||
button2: 'Custom Start Position',
|
||||
button3: 'Async Close',
|
||||
componentCall: 'Component Call',
|
||||
index: index => `Page: ${index}`
|
||||
}
|
||||
index: index => `Page: ${index}`,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
images,
|
||||
index: 0
|
||||
index: 0,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -86,7 +86,7 @@ export default {
|
||||
swipeDuration: 300,
|
||||
asyncClose: !!timer,
|
||||
closeOnPopstate: true,
|
||||
startPosition: typeof position === 'number' ? position : 0
|
||||
startPosition: typeof position === 'number' ? position : 0,
|
||||
});
|
||||
|
||||
if (timer) {
|
||||
@@ -94,8 +94,8 @@ export default {
|
||||
instance.close();
|
||||
}, timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ const defaultConfig = {
|
||||
startPosition: 0,
|
||||
swipeDuration: 500,
|
||||
showIndicators: false,
|
||||
closeOnPopstate: false
|
||||
closeOnPopstate: false,
|
||||
};
|
||||
|
||||
const initInstance = () => {
|
||||
instance = new (Vue.extend(VueImagePreview))({
|
||||
el: document.createElement('div')
|
||||
el: document.createElement('div'),
|
||||
});
|
||||
document.body.appendChild(instance.$el);
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ function triggerZoom(el, x, y) {
|
||||
const images = [
|
||||
'https://img.yzcdn.cn/1.png',
|
||||
'https://img.yzcdn.cn/2.png',
|
||||
'https://img.yzcdn.cn/3.png'
|
||||
'https://img.yzcdn.cn/3.png',
|
||||
];
|
||||
|
||||
test('render image', async () => {
|
||||
const wrapper = mount(ImagePreviewVue, {
|
||||
propsData: { images, value: true }
|
||||
propsData: { images, value: true },
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -43,13 +43,13 @@ test('async close prop', async () => {
|
||||
propsData: {
|
||||
images,
|
||||
value: true,
|
||||
asyncClose: true
|
||||
asyncClose: true,
|
||||
},
|
||||
listeners: {
|
||||
input(value) {
|
||||
wrapper.setProps({ value });
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const swipe = wrapper.find('.van-swipe__track');
|
||||
@@ -99,7 +99,7 @@ test('onClose option', () => {
|
||||
const instance = ImagePreview({
|
||||
images,
|
||||
startPostion: 1,
|
||||
onClose
|
||||
onClose,
|
||||
});
|
||||
|
||||
instance.close();
|
||||
@@ -115,7 +115,7 @@ test('onChange option', async done => {
|
||||
onChange(index) {
|
||||
expect(index).toEqual(2);
|
||||
done();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const swipe = instance.$el.querySelector('.van-swipe__track');
|
||||
@@ -132,7 +132,7 @@ test('zoom', async () => {
|
||||
Element.prototype.getBoundingClientRect = jest.fn(() => ({ width: 100 }));
|
||||
|
||||
const wrapper = mount(ImagePreviewVue, {
|
||||
propsData: { images, value: true }
|
||||
propsData: { images, value: true },
|
||||
});
|
||||
|
||||
const image = wrapper.find('img');
|
||||
@@ -146,8 +146,8 @@ test('set show-index prop to false', () => {
|
||||
const wrapper = mount(ImagePreviewVue, {
|
||||
propsData: {
|
||||
value: true,
|
||||
showIndex: false
|
||||
}
|
||||
showIndex: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -159,7 +159,7 @@ test('index slot', () => {
|
||||
<van-image-preview :value="true">
|
||||
<template #index>Custom Index</template>
|
||||
</van-image-preview>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -171,7 +171,7 @@ test('cover slot', () => {
|
||||
<van-image-preview :value="true">
|
||||
<template #cover>Custom Cover Content</template>
|
||||
</van-image-preview>
|
||||
`
|
||||
`,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -182,8 +182,8 @@ test('closeOnPopstate', () => {
|
||||
propsData: {
|
||||
images,
|
||||
value: true,
|
||||
closeOnPopstate: true
|
||||
}
|
||||
closeOnPopstate: true,
|
||||
},
|
||||
});
|
||||
|
||||
trigger(window, 'popstate');
|
||||
@@ -191,7 +191,7 @@ test('closeOnPopstate', () => {
|
||||
|
||||
wrapper.setProps({
|
||||
value: true,
|
||||
closeOnPopstate: false
|
||||
closeOnPopstate: false,
|
||||
});
|
||||
|
||||
trigger(window, 'popstate');
|
||||
@@ -202,12 +202,12 @@ test('lazy-load prop', () => {
|
||||
const wrapper = mount(ImagePreviewVue, {
|
||||
propsData: {
|
||||
images,
|
||||
lazyLoad: true
|
||||
}
|
||||
lazyLoad: true,
|
||||
},
|
||||
});
|
||||
|
||||
wrapper.setProps({
|
||||
value: true
|
||||
value: true,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
Reference in New Issue
Block a user