diff --git a/example/src/App.tsx b/example/src/App.tsx index 1225d3a..4d36312 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -28,7 +28,7 @@ function Routes() { animation, gestureDirection: "horizontal" }, - initialPath: '.', + initialPathname: '.', basePath: '/(react-motion-router/)?', disableBrowserRouting: isPWA() && isIOS(), }}> diff --git a/example/src/Screens/Overlays/index.tsx b/example/src/Screens/Overlays/index.tsx index c687968..1300236 100644 --- a/example/src/Screens/Overlays/index.tsx +++ b/example/src/Screens/Overlays/index.tsx @@ -34,7 +34,7 @@ export default function Overlays(props: OverlaysProps) {
{ - let router: RouterBase = this; + const activeRouters = [...this.#activeRoutersIter()]; // travel down router tree to find a router that can intercept - while (router?.child) { - if (router.child.canIntercept(e)) - router = router.child; - } - if (router.canIntercept(e)) { - router.intercept(e); + const interceptor = activeRouters.findLast(router => router.canIntercept(e)); + if (interceptor) { + interceptor.intercept(e); this.hasUAVisualTransition = e.hasUAVisualTransition; } } + *#activeRoutersIter() { + let router: RouterBase | null = this; + while (router) { + yield router; + router = router.child; + } + } + getRouterById(routerId: string, target?: RouterBase): RouterBase | null { const router = target ?? RouterBase.rootRouterRef?.deref(); if (router!.id === routerId) { @@ -166,7 +170,14 @@ export abstract class RouterBase
return new Promise