viewer: fix OTD
parent
883800c6ac
commit
8a84cd91c2
|
@ -45,6 +45,7 @@
|
||||||
<OnThisDay
|
<OnThisDay
|
||||||
v-if="$route.name === 'timeline'"
|
v-if="$route.name === 'timeline'"
|
||||||
:key="config_timelinePath"
|
:key="config_timelinePath"
|
||||||
|
:viewer="$refs.viewer"
|
||||||
@load="scrollerManager.adjust()"
|
@load="scrollerManager.adjust()"
|
||||||
>
|
>
|
||||||
</OnThisDay>
|
</OnThisDay>
|
||||||
|
|
|
@ -418,12 +418,8 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
|
|
||||||
// Get full image
|
// Get full image
|
||||||
return {
|
return {
|
||||||
src: getPreviewUrl(photo, false, 256),
|
...this.getItemData(photo),
|
||||||
msrc: thumbSrc,
|
msrc: thumbSrc,
|
||||||
width: photo.w || undefined,
|
|
||||||
height: photo.h || undefined,
|
|
||||||
thumbCropped: true,
|
|
||||||
photo: photo,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -436,6 +432,34 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
this.photoswipe.init();
|
this.photoswipe.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Open with a static list of photos */
|
||||||
|
public async openStatic(photo: IPhoto, list: IPhoto[]) {
|
||||||
|
this.list = list;
|
||||||
|
await this.createBase({
|
||||||
|
index: list.findIndex((p) => p.fileid === photo.fileid),
|
||||||
|
});
|
||||||
|
|
||||||
|
this.globalCount = list.length;
|
||||||
|
this.globalAnchor = 0;
|
||||||
|
|
||||||
|
this.photoswipe.addFilter("itemData", (itemData, index) => {
|
||||||
|
return this.getItemData(this.list[index]);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.photoswipe.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get base data object */
|
||||||
|
private getItemData(photo: IPhoto) {
|
||||||
|
return {
|
||||||
|
src: getPreviewUrl(photo, false, 256),
|
||||||
|
width: photo.w || undefined,
|
||||||
|
height: photo.h || undefined,
|
||||||
|
thumbCropped: true,
|
||||||
|
photo: photo,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/** Get element for thumbnail if it exists */
|
/** Get element for thumbnail if it exists */
|
||||||
private thumbElem(photo: IPhoto) {
|
private thumbElem(photo: IPhoto) {
|
||||||
if (!photo) return;
|
if (!photo) return;
|
||||||
|
@ -481,6 +505,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
this.updateLoading(1);
|
this.updateLoading(1);
|
||||||
for await (const p of dav.favoritePhotos([photo], val)) {
|
for await (const p of dav.favoritePhotos([photo], val)) {
|
||||||
if (!p[0]) return;
|
if (!p[0]) return;
|
||||||
|
this.$forceUpdate();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.updateLoading(-1);
|
this.updateLoading(-1);
|
||||||
|
|
|
@ -73,6 +73,9 @@ interface IYear {
|
||||||
export default class OnThisDay extends Mixins(GlobalMixin) {
|
export default class OnThisDay extends Mixins(GlobalMixin) {
|
||||||
private getPreviewUrl = getPreviewUrl;
|
private getPreviewUrl = getPreviewUrl;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
private viewer: any;
|
||||||
|
|
||||||
@Emit("load")
|
@Emit("load")
|
||||||
onload() {}
|
onload() {}
|
||||||
|
|
||||||
|
@ -191,7 +194,7 @@ export default class OnThisDay extends Mixins(GlobalMixin) {
|
||||||
|
|
||||||
click(year: IYear) {
|
click(year: IYear) {
|
||||||
const allPhotos = this.years.flatMap((y) => y.photos);
|
const allPhotos = this.years.flatMap((y) => y.photos);
|
||||||
// this.viewerManager.open(year.preview, allPhotos);
|
this.viewer.openStatic(year.preview, allPhotos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue