|
@@ -16,7 +16,7 @@
|
|
<div :class="[`${prefixCls}-header`]" v-if="!headerHide">
|
|
<div :class="[`${prefixCls}-header`]" v-if="!headerHide">
|
|
<h3>{{ curFile.name }}</h3>
|
|
<h3>{{ curFile.name }}</h3>
|
|
<div :class="[`${prefixCls}-index`]">
|
|
<div :class="[`${prefixCls}-index`]">
|
|
- {{ this.curIndex + 1 }} / {{ this.lastIndex }}
|
|
|
|
|
|
+ {{ this.curIndex + 1 }} / {{ this.lastIndex + 1 }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div :class="[`${prefixCls}-body`]" ref="ReviewBody">
|
|
<div :class="[`${prefixCls}-body`]" ref="ReviewBody">
|
|
@@ -39,6 +39,7 @@
|
|
]"
|
|
]"
|
|
:style="styles"
|
|
:style="styles"
|
|
v-move-ele.prevent="{ mouseMove }"
|
|
v-move-ele.prevent="{ mouseMove }"
|
|
|
|
+ v-show="!loading"
|
|
>
|
|
>
|
|
<img :src="curFile.url" :alt="curFile.name" ref="PreviewImgDetail" />
|
|
<img :src="curFile.url" :alt="curFile.name" ref="PreviewImgDetail" />
|
|
</div>
|
|
</div>
|
|
@@ -71,6 +72,13 @@
|
|
</li>
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <div :class="[`${prefixCls}-loading`]" v-show="loading">
|
|
|
|
+ <Icon class="ivu-load-loop" type="ios-loading" />
|
|
|
|
+ </div>
|
|
|
|
+ <div :class="[`${prefixCls}-preload`]">
|
|
|
|
+ <img v-for="(img, pindex) in preLoadFiles" :key="pindex" :src="img.url" />
|
|
|
|
+ </div>
|
|
</Modal>
|
|
</Modal>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -118,6 +126,9 @@ export default {
|
|
scale: 1,
|
|
scale: 1,
|
|
rotate: 0
|
|
rotate: 0
|
|
},
|
|
},
|
|
|
|
+ preLoadFiles: [],
|
|
|
|
+ loading: false,
|
|
|
|
+ loadingSetT: null,
|
|
nosition: false
|
|
nosition: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -126,10 +137,10 @@ export default {
|
|
return this.curIndex === 0;
|
|
return this.curIndex === 0;
|
|
},
|
|
},
|
|
isLast() {
|
|
isLast() {
|
|
- return this.lastIndex - 1 === this.curIndex;
|
|
|
|
|
|
+ return this.lastIndex === this.curIndex;
|
|
},
|
|
},
|
|
lastIndex() {
|
|
lastIndex() {
|
|
- return this.imageList.length;
|
|
|
|
|
|
+ return this.imageList.length - 1;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// watch: {
|
|
// watch: {
|
|
@@ -157,10 +168,13 @@ export default {
|
|
const index = val || 0;
|
|
const index = val || 0;
|
|
this.nosition = true;
|
|
this.nosition = true;
|
|
this.curFile = this.imageList[index];
|
|
this.curFile = this.imageList[index];
|
|
|
|
+ this.setPreloadFiles(index);
|
|
|
|
+ this.loadingSetT = setTimeout(() => {
|
|
|
|
+ this.loading = true;
|
|
|
|
+ }, 100);
|
|
},
|
|
},
|
|
registfileLoad() {
|
|
registfileLoad() {
|
|
const imgDom = this.$refs.PreviewImgDetail;
|
|
const imgDom = this.$refs.PreviewImgDetail;
|
|
-
|
|
|
|
imgDom.onload = () => {
|
|
imgDom.onload = () => {
|
|
const { naturalWidth, naturalHeight } = imgDom;
|
|
const { naturalWidth, naturalHeight } = imgDom;
|
|
const imageSize = this.getImageSizePos({
|
|
const imageSize = this.getImageSizePos({
|
|
@@ -186,11 +200,30 @@ export default {
|
|
scale: 1,
|
|
scale: 1,
|
|
rotate: 0
|
|
rotate: 0
|
|
};
|
|
};
|
|
|
|
+ if (this.loadingSetT) clearTimeout(this.loadingSetT);
|
|
|
|
+ this.loading = false;
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
this.nosition = false;
|
|
this.nosition = false;
|
|
}, 100);
|
|
}, 100);
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ setPreloadFiles(curIndex) {
|
|
|
|
+ let preLoadIndexs = [];
|
|
|
|
+ if (this.loop) {
|
|
|
|
+ preLoadIndexs = [
|
|
|
|
+ curIndex === 0 ? this.lastIndex : curIndex - 1,
|
|
|
|
+ curIndex === this.lastIndex ? 0 : curIndex + 1
|
|
|
|
+ ];
|
|
|
|
+ } else {
|
|
|
|
+ preLoadIndexs = [
|
|
|
|
+ curIndex === 0 ? null : curIndex - 1,
|
|
|
|
+ curIndex === this.lastIndex ? null : curIndex + 1
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ this.preLoadFiles = preLoadIndexs
|
|
|
|
+ .filter(item => item !== null)
|
|
|
|
+ .map(item => this.imageList[item]);
|
|
|
|
+ },
|
|
getImageSizePos({ win, img, rotate }) {
|
|
getImageSizePos({ win, img, rotate }) {
|
|
const imageSize = {
|
|
const imageSize = {
|
|
width: 0,
|
|
width: 0,
|
|
@@ -236,7 +269,7 @@ export default {
|
|
showPrev() {
|
|
showPrev() {
|
|
if (this.isFirst) {
|
|
if (this.isFirst) {
|
|
if (this.loop) {
|
|
if (this.loop) {
|
|
- this.curIndex = this.lastIndex - 1;
|
|
|
|
|
|
+ this.curIndex = this.lastIndex;
|
|
} else {
|
|
} else {
|
|
this.$emit("on-page-prev");
|
|
this.$emit("on-page-prev");
|
|
return;
|
|
return;
|
|
@@ -308,16 +341,16 @@ export default {
|
|
left: imageSize.left + "px"
|
|
left: imageSize.left + "px"
|
|
});
|
|
});
|
|
// 360度无缝切换到0度
|
|
// 360度无缝切换到0度
|
|
- setTimeout(() => {
|
|
|
|
- if (this.transform.rotate >= 360) {
|
|
|
|
|
|
+ if (this.transform.rotate >= 360) {
|
|
|
|
+ setTimeout(() => {
|
|
this.nosition = true;
|
|
this.nosition = true;
|
|
this.transform.rotate = 0;
|
|
this.transform.rotate = 0;
|
|
this.setStyleTransform();
|
|
this.setStyleTransform();
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
this.nosition = false;
|
|
this.nosition = false;
|
|
}, 100);
|
|
}, 100);
|
|
- }
|
|
|
|
- }, 200);
|
|
|
|
|
|
+ }, 200);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|