feat(nav): add back button to FavoritesView and scroll position memory
FavoritesView now has a conditional back button (shown when onBack prop is provided). Added scroll position save/restore infrastructure to navigationStore (saveScrollPosition/getSavedScrollPosition keyed by ViewType). FavoritesView saves scroll position on scroll and restores it when returning to the view.
This commit is contained in:
1 parent
7631ed3e20
commit
be80ce1470
3 files changed
+62
-2
No files matched your search
@@ -30,6 +30,9 @@ let activeView: ViewType = 'home';
|
||||
let viewHistory: ViewType[] = ['home'];
|
||||
let forwardHistory: ViewType[] = [];
|
||||
|
||||
// Scroll position memory — keyed by ViewType
|
||||
const scrollPositions = new Map<ViewType, number>();
|
||||
|
||||
// Selected playlist ID (album/artist are full data objects in +page.svelte)
|
||||
let selectedPlaylistId: number | null = null;
|
||||
|
||||
@@ -222,6 +225,22 @@ export function navigateToFavorites(tab?: FavoritesTab): void {
|
||||
navigateTo(favoritesViewForTab(targetTab));
|
||||
}
|
||||
|
||||
// ============ Scroll Position ============
|
||||
|
||||
/**
|
||||
* Save scroll position for a view (call before navigating away)
|
||||
*/
|
||||
export function saveScrollPosition(view: ViewType, scrollTop: number): void {
|
||||
scrollPositions.set(view, scrollTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get saved scroll position for a view (0 if none saved)
|
||||
*/
|
||||
export function getSavedScrollPosition(view: ViewType): number {
|
||||
return scrollPositions.get(view) ?? 0;
|
||||
}
|
||||
|
||||
// ============ Getters ============
|
||||
|
||||
export function getActiveView(): ViewType {
|
||||
|
||||
Reference in new issue
Block a user