Animate orders out with a CSS transition instead of the View Transitions API
The prior attempt wrapped the sign-out router.invalidate() in document.startViewTransition(), but that had two problems: invalidate() does its own network refetch inside the transition's update callback, which freezes the page for the round-trip instead of animating anything, and TanStack Router's invalidate() explicitly opts itself out of view transitions (sets shouldViewTransition = false) for exactly that reason. On top of that, OrdersRoute briefly returns null between the account loader clearing and the guest-orders lookup resolving, unmounting OrdersListView and wiping any exit-animation state anyway. Replace it with a plain, self-contained approach: - OrdersRoute now keeps rendering the last known non-null orders list through that brief gap (a lastKnownOrders ref) instead of unmounting OrdersListView, so its local animation state survives. - OrdersListView holds onto the previous non-empty list for EXIT_DURATION_MS after it goes empty, applying an `orderExiting` class that fades/slides each card out via a plain CSS transition, then swaps to the actual empty state once the transition finishes. This has no dependency on browser view-transition support, network timing, or router internals. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -71,13 +71,21 @@
|
||||
background: $color-surface;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transition: border-color 0.15s ease;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
opacity 0.28s ease,
|
||||
transform 0.28s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: $color-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.orderExiting .order {
|
||||
opacity: 0;
|
||||
transform: translateY(-8px) scale(0.98);
|
||||
}
|
||||
|
||||
.orderHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in New Issue
Block a user