Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

fix: handle interrupted book transitions

yzrbea4d80d7903
diff --git a/site/index.html b/site/index.html
index 8887dc2..1d2a7ee 100644
--- a/site/index.html
+++ b/site/index.html
@@ -262,8 +262,12 @@ function show(animate) {
heading?.focus({ preventScroll: true });
}
};
- if (animate && document.startViewTransition && !reduced) document.startViewTransition(apply).ready.catch(() => {}); // an interrupted transition just ends
- else apply();
+ if (animate && document.startViewTransition && !reduced) {
+ const transition = document.startViewTransition(apply);
+ // Navigation can interrupt either promise; the new view is already applied.
+ transition.ready.catch(() => {});
+ transition.finished.catch(() => {});
+ } else apply();
}
addEventListener('hashchange', () => show(true));
show(false);