Skip to content

Commit

Permalink
add scroll to top element when pressing the 'i' or clicking on detail…
Browse files Browse the repository at this point in the history
…s in albums
  • Loading branch information
ildyria committed Dec 27, 2024
1 parent 148ec74 commit 282e049
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion resources/js/components/headers/AlbumHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const props = defineProps<{
user: App.Http.Resources.Models.UserResource;
}>();
const toggleDetails = () => (are_details_open.value = !are_details_open.value);
const togglableStore = useTogglablesStateStore();
const lycheeStore = useLycheeStateStore();
lycheeStore.init();
Expand All @@ -101,6 +100,7 @@ const { toggleCreateAlbum, isImportFromLinkOpen, toggleImportFromLink, isImportF
const emits = defineEmits<{
refresh: [];
toggleSlideShow: [];
toggleDetails: [];
}>();
function toggleUploadTrack() {
Expand All @@ -111,6 +111,13 @@ function toggleSlideShow() {
emits("toggleSlideShow");
}
function toggleDetails() {
are_details_open.value = !are_details_open.value;
if (are_details_open.value) {
emits("toggleDetails");
}
}
function uploadTrack(e: Event) {
const target: HTMLInputElement = e.target as HTMLInputElement;
if (target.files === null) {
Expand Down
6 changes: 6 additions & 0 deletions resources/js/composables/album/scrollable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ export function useScrollable(toggleableStore: TogglablesStateStore, path: Ref<s
}
}

function scrollToTop() {
const e = document.getElementById("galleryView") as HTMLElement;
e.scrollTop = 0;
}

return {
onScroll,
setScroll,
scrollToTop,
};
}
7 changes: 6 additions & 1 deletion resources/js/views/gallery-panels/Album.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:user="user"
@refresh="refresh"
@toggle-slide-show="toggleSlideShow"
@toggle-details="toggleDetails"
/>
</Collapse>
<Unlock :albumid="albumid" :visible="isPasswordProtected" @reload="refresh" @fail="is_login_open = true" />
Expand Down Expand Up @@ -232,7 +233,7 @@ const lycheeStore = useLycheeStateStore();
lycheeStore.init();
togglableStore.resetSearch();
const { onScroll, setScroll } = useScrollable(togglableStore, albumid);
const { onScroll, setScroll, scrollToTop } = useScrollable(togglableStore, albumid);
const { is_full_screen, is_login_open, is_slideshow_active, is_upload_visible, list_upload_files } = storeToRefs(togglableStore);
const { are_nsfw_visible, nsfw_consented, is_se_enabled } = storeToRefs(lycheeStore);
Expand Down Expand Up @@ -287,6 +288,10 @@ function toggleStatistics() {
}
}
function toggleDetails() {
scrollToTop();
}
const {
selectedPhotosIdx,
selectedAlbumsIdx,
Expand Down

0 comments on commit 282e049

Please sign in to comment.