fix(showcase): reset gallery position when loading a model's examples

The module-level galleryState kept activeIndex/expanded across models
(the modal is a singleton), so opening model B after navigating model A
started B's gallery at A's last index. Reset activeIndex, expanded and
lastNavDirection in loadExampleImages, the per-model entry point.
This commit is contained in:
Will Miao
2026-09-01 22:54:36 +08:00
parent f7b247f9e8
commit 34ca14d7fc
2 changed files with 36 additions and 0 deletions
@@ -54,6 +54,13 @@ export async function loadExampleImages(images, modelHash, previewUrl = '') {
const showcaseTab = document.getElementById('showcase-tab');
if (!showcaseTab) return;
// Fresh load of a model's examples: reset the gallery position so a
// previously viewed model's active index / expansion state never leaks
// into this one (the modal is a singleton, state is module-level)
galleryState.activeIndex = 0;
galleryState.expanded = false;
lastNavDirection = 1;
// First fetch local example files
let localFiles = [];