Skip to content

Commit 6a28071

Browse files
committed
fix: 一覧画面から遷移する直前のスクロール位置を保存し、一覧に戻った際にスクロール位置を自動復元する機能を実装
1 parent 87caba6 commit 6a28071

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/views/MobileCompanion.svelte

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
let cachedAt: string | null = null;
135135
let didReceiveLibrary = false;
136136
let didSelectGameManually = false;
137+
let libraryScrollTop = 0;
138+
let lastActiveView: ViewMode = activeView;
137139
let imageUrlsByPath: Record<string, string> = {};
138140
let pendingImages = new Map<number, PendingImage>();
139141
let objectUrls: string[] = [];
@@ -293,6 +295,16 @@
293295
requestThumbnailsForGames(visibleThumbnailGames);
294296
}
295297
298+
$: {
299+
if (lastActiveView === "library" && activeView !== "library") {
300+
const container = document.querySelector(".content");
301+
if (container) {
302+
libraryScrollTop = container.scrollTop;
303+
}
304+
}
305+
lastActiveView = activeView;
306+
}
307+
296308
$: if (activeView === "detail") {
297309
selectedGameId;
298310
void tick().then(() => {
@@ -303,6 +315,15 @@
303315
});
304316
}
305317
318+
$: if (activeView === "library") {
319+
void tick().then(() => {
320+
const container = document.querySelector(".content");
321+
if (container) {
322+
container.scrollTop = libraryScrollTop;
323+
}
324+
});
325+
}
326+
306327
const isObject = (value: unknown): value is Record<string, unknown> =>
307328
!!value && typeof value === "object";
308329

0 commit comments

Comments
 (0)