[bugfix] ImagePreview: can't be closed when contain single image (#1046)

This commit is contained in:
neverland 2018-05-12 10:54:32 +08:00 committed by GitHub
parent 3c1e3947fd
commit df2bc56aff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
<template> <template>
<div :class="b()"> <div :class="b()">
<div <div
v-if="count > 1"
:style="trackStyle" :style="trackStyle"
:class="b('track')" :class="b('track')"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@ -12,9 +11,6 @@
> >
<slot /> <slot />
</div> </div>
<div v-else :class="b('track')">
<slot />
</div>
<div <div
v-if="showIndicators && count > 1" v-if="showIndicators && count > 1"
:class="b('indicators', { vertical })" :class="b('indicators', { vertical })"
@ -185,12 +181,9 @@ export default create({
const { delta, active, count, swipes, trackSize } = this; const { delta, active, count, swipes, trackSize } = this;
const atFirst = active === 0; const atFirst = active === 0;
const atLast = active === count - 1; const atLast = active === count - 1;
const outOfBounds = !this.loop && ((atFirst && (offset > 0 || move < 0)) || (atLast && (offset < 0 || move > 0)));
if ( if (outOfBounds || count <= 1) {
!this.loop &&
((atFirst && (offset > 0 || move < 0)) ||
(atLast && (offset < 0 || move > 0)))
) {
return; return;
} }