ui-router-navigation-location-plugin / NavigationLocationPluginOptions
Interface: NavigationLocationPluginOptions
Defined in: index.ts:85
Options for navigationLocationPlugin.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
intercept? | (event) => NavigationInterceptOptions | Called for each navigation the service itself starts, after the router transition has committed. What it returns is handed to event.intercept(): handler decides what navigation.transition.finished waits on and when the browser runs focus reset and scroll restoration, and focusReset and scroll pass through. The router is available as event.info.uiRouter. focusReset defaults to 'manual', so focus stays where it was, as under pushStateLocationPlugin. Return focusReset: 'after-transition' to have the browser move focus to <body> after each navigation instead. Absent, the service intercepts with an immediately resolving handler. Example import type { UIRouter } from '@uirouter/core'; import { navigationLocationPlugin, type NavigationLocationPluginOptions, } from 'ui-router-navigation-location-plugin'; declare const router: UIRouter; router.plugin(navigationLocationPlugin, { intercept: (event) => ({ async handler() { // view transitions, analytics, progress UI }, }), } satisfies NavigationLocationPluginOptions); | index.ts:120 |
interceptTraverse? | | true | ((event) => NavigationTraverseInterceptOptions) | Intercepts back/forward traversals of this document, so the browser restores scroll, and resets focus if asked to, once the router transition the traversal starts has settled. Absent, the service leaves traversals alone and the browser restores their scroll position straight away, before the router transition the traversal starts has run. Passed, the service intercepts each traverse navigation it can intercept, other than one this plugin started itself, with a handler that waits for that router transition, including its redirects, to settle. A superseding navigation ends the wait. Pass true for the defaults, or a function whose return value is handed to event.intercept(). The function runs at navigate time, before the router transition exists, so focusReset and scroll are fixed before the destination state is known. Its handler runs after the router transition settles and receives it, so it can read the destination state's data; return scroll: 'manual' and call event.scroll() from the handler to restore scroll only for the states that want it. The service forces a layout once the handler settles, so the browser restores scroll against the rendered view. focusReset and scroll pass through; focusReset defaults to 'manual', as for intercept. Example import type { UIRouter } from '@uirouter/core'; import { navigationLocationPlugin, type NavigationLocationPluginOptions, } from 'ui-router-navigation-location-plugin'; declare const router: UIRouter; router.plugin(navigationLocationPlugin, { interceptTraverse: (event) => ({ scroll: 'manual', async handler(transition) { if (!transition?.to().data?.keepScroll) { await new Promise(requestAnimationFrame); event.scroll(); } }, }), } satisfies NavigationLocationPluginOptions); | index.ts:168 |