move restoring og photo scroll position into own function
This commit is contained in:
parent
3e33af7d1d
commit
00ed6468c3
1 changed files with 17 additions and 11 deletions
|
@ -494,17 +494,8 @@ export default {
|
|||
if (this.$root.$el.clientHeight <= window.document.documentElement.clientHeight + 300) {
|
||||
this.$emit("scrollRefresh");
|
||||
}
|
||||
const lastOpenedPhotoId = window.localStorage.getItem("last_opened_photo");
|
||||
if (!this.viewer.open && lastOpenedPhotoId) {
|
||||
window.localStorage.removeItem("last_opened_photo");
|
||||
this.$nextTick(() => {
|
||||
document.querySelector(`[data-uid="${lastOpenedPhotoId}"]`)?.scrollIntoView({
|
||||
behavior: 'auto',
|
||||
block: 'center',
|
||||
inline: 'center'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.restoreScrollPosition();
|
||||
});
|
||||
}
|
||||
}).finally(() => {
|
||||
|
@ -513,6 +504,21 @@ export default {
|
|||
this.listen = true;
|
||||
});
|
||||
},
|
||||
restoreScrollPosition() {
|
||||
const lastOpenedPhotoId = window.localStorage.getItem("last_opened_photo");
|
||||
if (lastOpenedPhotoId === undefined || lastOpenedPhotoId === null || this.viewer.open) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.localStorage.removeItem("last_opened_photo");
|
||||
this.$nextTick(() => {
|
||||
document.querySelector(`[data-uid="${lastOpenedPhotoId}"]`)?.scrollIntoView({
|
||||
behavior: 'auto',
|
||||
block: 'center',
|
||||
inline: 'center'
|
||||
});
|
||||
});
|
||||
},
|
||||
onImportCompleted() {
|
||||
if (!this.listen) return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue