Files
readest/apps/readest-app/src/utils/viewTransition.ts
T
Huang Xin 600d69fa50 fix(reader): gate route View Transitions on API support (READEST-9) (#4989)
* fix(reader): gate route View Transitions on the API, turns on groups (READEST-9)

Reverts #4949, which opened books through the plain router to dodge the
"Transition was aborted because of timeout in DOM update" TimeoutError
(Sentry READEST-9). Rather than carve the transition out of one flow, gate it
at the router: useAppRouter routes through the View Transition router only
where the engine has the View Transitions API, and every into-reader path
(including the reverted ones) goes back through useAppRouter.

The base View Transitions API and nested view-transition groups reach very
different browsers, so they become two separate appService capability flags,
each backed by a probe in utils/viewTransition:

* supportsViewTransitionsAPI (document.startViewTransition): the baseline a
  route crossfade needs, landing on Chrome 111+, Safari 18+, recent WebView.
  Gates the router.
* supportsViewTransitionGroup (view-transition-group: nearest, Chrome/WebView
  140+): the far narrower target the paginator's layered turns require. Gates
  the turn-style options and the captured-turn fallback.

Both flags fold in the Linux WebKitGTK carve-out because it crashes on the
snapshot, matching the supportsCanvasContext2DFilter precedent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(tts): enlarge the Now Playing bar and scale its controls responsively

Grow the collapsed bar to h-14 with a 10x10 cover and symmetric px-2 padding,
drive the play/pause and close icons through useResponsiveSize instead of fixed
pixel sizes, and cut the bottom safe-area contribution to a third so the bar
sits closer to the screen edge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 09:20:06 +02:00

23 lines
1016 B
TypeScript

/**
* Whether the engine implements the View Transitions API at all
* (`document.startViewTransition`). This is the baseline a simple route
* crossfade needs, and it lands broadly: Chrome 111+, Edge, Safari 18+, and
* recent Android WebView.
*/
export const detectViewTransitionsAPI = (): boolean =>
typeof document !== 'undefined' && 'startViewTransition' in document;
/**
* Whether the engine also supports nested view-transition groups
* (`view-transition-group: nearest`, Chrome/WebView 140+) - a far narrower
* target than the base API. This is what the paginator's layered turns
* require: iOS 18 WebKit ships `startViewTransition` but crashes the
* WebContent process on layered snapshots, so the group query marks the
* mature engines where the layered turns are known to work.
*/
export const detectViewTransitionGroup = (): boolean =>
detectViewTransitionsAPI() &&
typeof CSS !== 'undefined' &&
typeof CSS.supports === 'function' &&
CSS.supports('view-transition-group', 'nearest');