mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
revert(mobile): keep the page transitions' timing and drop the unused route preload
The previous commit carried, by mistake, shorter page transitions and a route preloader that was never wired up. Both go back to how they were; the warm-up and day rail fixes stay.
This commit is contained in:
@@ -453,23 +453,23 @@
|
||||
}
|
||||
}
|
||||
:root[data-route-transition='forward']::view-transition-old(root) {
|
||||
animation: m-vt-out-leading 0.3s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
animation: m-vt-out-leading 0.4s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
}
|
||||
:root[data-route-transition='forward']::view-transition-new(root) {
|
||||
animation: m-vt-in-trailing 0.3s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
animation: m-vt-in-trailing 0.4s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
box-shadow: -16px 0 40px -12px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
:root[data-route-transition='back']::view-transition-old(root) {
|
||||
z-index: 1;
|
||||
animation: m-vt-out-trailing 0.26s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
animation: m-vt-out-trailing 0.34s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
box-shadow: -16px 0 40px -12px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
:root[data-route-transition='back']::view-transition-new(root) {
|
||||
animation: m-vt-in-leading 0.26s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
animation: m-vt-in-leading 0.34s cubic-bezier(0.32, 0.72, 0, 1) both;
|
||||
}
|
||||
:root[data-route-transition='tab']::view-transition-old(root),
|
||||
:root[data-route-transition='tab']::view-transition-new(root) {
|
||||
animation-duration: 0.15s;
|
||||
animation-duration: 0.18s;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
::view-transition-group(*),
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { Location, NavigationType } from 'react-router';
|
||||
*/
|
||||
export type RouteTransitionKind = 'forward' | 'back' | 'tab';
|
||||
|
||||
const SETTLE_MS = 300;
|
||||
const SETTLE_MS = 800;
|
||||
let skipNext = false;
|
||||
let current: ViewTransition | null = null;
|
||||
|
||||
|
||||
@@ -44,33 +44,9 @@ export function retryUrlFor(error: unknown): string | null {
|
||||
return busted.href;
|
||||
}
|
||||
|
||||
/** Every route loader, so the phone can fetch them ahead while idle (preloadLazyRoutes). */
|
||||
const loaders: (() => Promise<unknown>)[] = [];
|
||||
|
||||
/**
|
||||
* Fetches every lazily loaded page in the background, a few at a time, so
|
||||
* opening one later does not wait for the network. A loader that fails is
|
||||
* simply tried again when the page is opened. Skipped where the user asked to
|
||||
* save data.
|
||||
*/
|
||||
export function preloadLazyRoutes(): void {
|
||||
const connection = (navigator as { connection?: { saveData?: boolean } }).connection;
|
||||
if (connection?.saveData) return;
|
||||
const queue = [...loaders];
|
||||
const next = () => {
|
||||
const load = queue.shift();
|
||||
if (!load) return;
|
||||
void load()
|
||||
.catch(() => {})
|
||||
.then(next);
|
||||
};
|
||||
for (let i = 0; i < 3; i++) next();
|
||||
}
|
||||
|
||||
export function lazyWithRetry<T extends ComponentType<any>>(
|
||||
load: () => Promise<{ default: T }>
|
||||
): LazyExoticComponent<T> {
|
||||
loaders.push(load);
|
||||
return lazy(() =>
|
||||
load()
|
||||
.catch((error: unknown) => {
|
||||
|
||||
Reference in New Issue
Block a user