Add complete check
parent
2618e3ff20
commit
7138768551
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,8 @@
|
||||||
height: rowHeight + 'px',
|
height: rowHeight + 'px',
|
||||||
}">
|
}">
|
||||||
<img
|
<img
|
||||||
:src="getUrl()"
|
ref="image"
|
||||||
|
:src="getSrc()"
|
||||||
:key="data.fileid"
|
:key="data.fileid"
|
||||||
|
|
||||||
@click="click"
|
@click="click"
|
||||||
|
@ -57,8 +58,8 @@ export default class Photo extends Mixins(GlobalMixin) {
|
||||||
@Emit('select') emitSelect(data: IPhoto) {}
|
@Emit('select') emitSelect(data: IPhoto) {}
|
||||||
@Emit('clickImg') emitClickImg(component: any) {}
|
@Emit('clickImg') emitClickImg(component: any) {}
|
||||||
|
|
||||||
/** Get URL for image to show */
|
/** Get src for image to show */
|
||||||
getUrl() {
|
getSrc() {
|
||||||
if (this.data.flag & this.c.FLAG_PLACEHOLDER) {
|
if (this.data.flag & this.c.FLAG_PLACEHOLDER) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else if (this.data.flag & this.c.FLAG_LOAD_FAIL) {
|
} else if (this.data.flag & this.c.FLAG_LOAD_FAIL) {
|
||||||
|
@ -67,14 +68,28 @@ export default class Photo extends Mixins(GlobalMixin) {
|
||||||
this.data.flag &= ~this.c.FLAG_FORCE_RELOAD;
|
this.data.flag &= ~this.c.FLAG_FORCE_RELOAD;
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return getPreviewUrl(this.data.fileid, this.data.etag);
|
return this.getUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get url of the photo */
|
||||||
|
getUrl() {
|
||||||
|
return getPreviewUrl(this.data.fileid, this.data.etag);
|
||||||
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
// Check if current image already loaded
|
||||||
|
if (this.data?.fileid) {
|
||||||
|
const img = this.$refs.image as HTMLImageElement;
|
||||||
|
if (img.complete && img.src === this.getUrl()) {
|
||||||
|
this.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Image loaded successfully */
|
/** Image loaded successfully */
|
||||||
load() {
|
load() {
|
||||||
this.data.flag |= this.c.FLAG_LOADED;
|
this.data.flag |= this.c.FLAG_LOADED;
|
||||||
this.$forceUpdate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Error in loading image */
|
/** Error in loading image */
|
||||||
|
|
Loading…
Reference in New Issue