2017-02-01 16:13:57 -05:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {Route} from './config';
|
2017-09-04 16:00:59 -04:00
|
|
|
import {ActivatedRouteSnapshot, RouterStateSnapshot} from './router_state';
|
|
|
|
|
2018-01-24 12:19:59 -05:00
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Identifies the trigger of the navigation.
|
2018-01-24 12:19:59 -05:00
|
|
|
*
|
|
|
|
* * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
|
|
|
|
* * 'popstate'--triggered by a popstate event
|
|
|
|
* * 'hashchange'--triggered by a hashchange event
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2018-01-24 12:19:59 -05:00
|
|
|
*/
|
|
|
|
export type NavigationTrigger = 'imperative' | 'popstate' | 'hashchange';
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Base for events the Router goes through, as opposed to events tied to a specific
|
2017-07-25 14:13:15 -04:00
|
|
|
* Route. `RouterEvent`s will only be fired one time for any given navigation.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2017-07-25 14:13:15 -04:00
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* class MyService {
|
|
|
|
* constructor(public router: Router, logger: Logger) {
|
|
|
|
* router.events.filter(e => e instanceof RouterEvent).subscribe(e => {
|
|
|
|
* logger.log(e.id, e.url);
|
|
|
|
* });
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public id: number,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public url: string) {}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
2017-07-25 14:13:15 -04:00
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered when a navigation starts.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
|
|
|
export class NavigationStart extends RouterEvent {
|
2018-01-24 12:19:59 -05:00
|
|
|
/**
|
|
|
|
* Identifies the trigger of the navigation.
|
|
|
|
*
|
|
|
|
* * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
|
|
|
|
* * 'popstate'--triggered by a popstate event
|
|
|
|
* * 'hashchange'--triggered by a hashchange event
|
|
|
|
*/
|
|
|
|
navigationTrigger?: 'imperative'|'popstate'|'hashchange';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This contains the navigation id that pushed the history record that the router navigates
|
|
|
|
* back to. This is not null only when the navigation is triggered by a popstate event.
|
|
|
|
*
|
|
|
|
* The router assigns a navigationId to every router transition/navigation. Even when the user
|
|
|
|
* clicks on the back button in the browser, a new navigation id will be created. So from
|
|
|
|
* the perspective of the router, the router never "goes back". By using the `restoredState`
|
|
|
|
* and its navigationId, you can implement behavior that differentiates between creating new
|
|
|
|
* states
|
|
|
|
* and popstate events. In the latter case you can restore some remembered state (e.g., scroll
|
|
|
|
* position).
|
|
|
|
*/
|
|
|
|
restoredState?: {navigationId: number}|null;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
id: number,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
url: string,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
navigationTrigger: 'imperative'|'popstate'|'hashchange' = 'imperative',
|
|
|
|
/** @docsNotRequired */
|
|
|
|
restoredState: {navigationId: number}|null = null) {
|
|
|
|
super(id, url);
|
|
|
|
this.navigationTrigger = navigationTrigger;
|
|
|
|
this.restoredState = restoredState;
|
|
|
|
}
|
|
|
|
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string { return `NavigationStart(id: ${this.id}, url: '${this.url}')`; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered when a navigation ends successfully.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class NavigationEnd extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public urlAfterRedirects: string) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string {
|
|
|
|
return `NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered when a navigation is canceled.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class NavigationCancel extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public reason: string) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string { return `NavigationCancel(id: ${this.id}, url: '${this.url}')`; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered when a navigation fails due to an unexpected error.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class NavigationError extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public error: any) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string {
|
|
|
|
return `NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered when routes are recognized.
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class RoutesRecognized extends RouterEvent {
|
2017-02-01 16:13:57 -05:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-02-01 16:13:57 -05:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-02-01 16:13:57 -05:00
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
toString(): string {
|
|
|
|
return `RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the start of the Guard phase of routing.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class GuardsCheckStart extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
|
|
|
return `GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the end of the Guard phase of routing.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class GuardsCheckEnd extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public state: RouterStateSnapshot,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public shouldActivate: boolean) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
|
|
|
return `GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the start of the Resolve phase of routing. The timing of this
|
2017-07-01 13:30:17 -04:00
|
|
|
* event may change, thus it's experimental. In the current iteration it will run
|
|
|
|
* in the "resolve" phase whether there's things to resolve or not. In the future this
|
|
|
|
* behavior may change to only run when there are things to be resolved.
|
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class ResolveStart extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
|
|
|
return `ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the end of the Resolve phase of routing. See note on
|
2018-04-05 06:53:57 -04:00
|
|
|
* `ResolveStart` for use of this experimental API.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-01 13:30:17 -04:00
|
|
|
*/
|
2017-07-25 14:13:15 -04:00
|
|
|
export class ResolveEnd extends RouterEvent {
|
2017-07-01 13:30:17 -04:00
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
id: number,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
url: string,
|
2017-07-01 13:30:17 -04:00
|
|
|
/** @docsNotRequired */
|
|
|
|
public urlAfterRedirects: string,
|
|
|
|
/** @docsNotRequired */
|
2017-07-25 14:13:15 -04:00
|
|
|
public state: RouterStateSnapshot) {
|
|
|
|
super(id, url);
|
|
|
|
}
|
2017-07-01 13:30:17 -04:00
|
|
|
|
|
|
|
toString(): string {
|
|
|
|
return `ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-25 14:13:15 -04:00
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered before lazy loading a route config.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class RouteConfigLoadStart {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public route: Route) {}
|
2017-07-25 14:13:15 -04:00
|
|
|
toString(): string { return `RouteConfigLoadStart(path: ${this.route.path})`; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents an event triggered when a route has been lazy loaded.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class RouteConfigLoadEnd {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public route: Route) {}
|
2017-07-25 14:13:15 -04:00
|
|
|
toString(): string { return `RouteConfigLoadEnd(path: ${this.route.path})`; }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the start of end of the Resolve phase of routing. See note on
|
2018-04-05 06:53:57 -04:00
|
|
|
* `ChildActivationEnd` for use of this experimental API.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class ChildActivationStart {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-09-04 16:00:59 -04:00
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
|
|
|
return `ChildActivationStart(path: '${path}')`;
|
|
|
|
}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the start of end of the Resolve phase of routing. See note on
|
2018-04-05 06:53:57 -04:00
|
|
|
* `ChildActivationStart` for use of this experimental API.
|
2017-07-25 14:13:15 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-07-25 14:13:15 -04:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export class ChildActivationEnd {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
2017-09-04 16:00:59 -04:00
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
|
|
|
return `ChildActivationEnd(path: '${path}')`;
|
|
|
|
}
|
2017-07-25 14:13:15 -04:00
|
|
|
}
|
|
|
|
|
2017-09-06 14:00:32 -04:00
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the start of end of the Resolve phase of routing. See note on
|
2018-04-05 06:53:57 -04:00
|
|
|
* `ActivationEnd` for use of this experimental API.
|
2017-09-06 14:00:32 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-09-06 14:00:32 -04:00
|
|
|
*/
|
|
|
|
export class ActivationStart {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
2017-09-11 14:27:33 -04:00
|
|
|
return `ActivationStart(path: '${path}')`;
|
2017-09-06 14:00:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents the start of end of the Resolve phase of routing. See note on
|
2018-04-05 06:53:57 -04:00
|
|
|
* `ActivationStart` for use of this experimental API.
|
2017-09-06 14:00:32 -04:00
|
|
|
*
|
2018-10-19 07:12:20 -04:00
|
|
|
* @publicApi
|
2017-09-06 14:00:32 -04:00
|
|
|
*/
|
|
|
|
export class ActivationEnd {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
public snapshot: ActivatedRouteSnapshot) {}
|
|
|
|
toString(): string {
|
|
|
|
const path = this.snapshot.routeConfig && this.snapshot.routeConfig.path || '';
|
2017-09-11 14:27:33 -04:00
|
|
|
return `ActivationEnd(path: '${path}')`;
|
2017-09-06 14:00:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-17 07:33:50 -04:00
|
|
|
/**
|
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents a scrolling event.
|
|
|
|
*/
|
|
|
|
export class Scroll {
|
|
|
|
constructor(
|
|
|
|
/** @docsNotRequired */
|
|
|
|
readonly routerEvent: NavigationEnd,
|
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
readonly position: [number, number]|null,
|
|
|
|
|
|
|
|
/** @docsNotRequired */
|
|
|
|
readonly anchor: string|null) {}
|
|
|
|
|
|
|
|
toString(): string {
|
|
|
|
const pos = this.position ? `${this.position[0]}, ${this.position[1]}` : null;
|
|
|
|
return `Scroll(anchor: '${this.anchor}', position: '${pos}')`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-01 13:30:17 -04:00
|
|
|
/**
|
2018-04-05 06:51:21 -04:00
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Represents a router event, allowing you to track the lifecycle of the router.
|
2017-07-01 13:30:17 -04:00
|
|
|
*
|
|
|
|
* The sequence of router events is:
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-04-05 06:53:57 -04:00
|
|
|
* - `NavigationStart`,
|
|
|
|
* - `RouteConfigLoadStart`,
|
|
|
|
* - `RouteConfigLoadEnd`,
|
|
|
|
* - `RoutesRecognized`,
|
|
|
|
* - `GuardsCheckStart`,
|
|
|
|
* - `ChildActivationStart`,
|
|
|
|
* - `ActivationStart`,
|
|
|
|
* - `GuardsCheckEnd`,
|
|
|
|
* - `ResolveStart`,
|
|
|
|
* - `ResolveEnd`,
|
|
|
|
* - `ActivationEnd`
|
|
|
|
* - `ChildActivationEnd`
|
|
|
|
* - `NavigationEnd`,
|
|
|
|
* - `NavigationCancel`,
|
|
|
|
* - `NavigationError`
|
2018-05-17 07:33:50 -04:00
|
|
|
* - `Scroll`
|
2017-02-01 16:13:57 -05:00
|
|
|
*
|
2018-04-05 17:31:44 -04:00
|
|
|
*
|
2017-02-01 16:13:57 -05:00
|
|
|
*/
|
2017-09-05 14:54:33 -04:00
|
|
|
export type Event = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart |
|
2018-05-17 07:33:50 -04:00
|
|
|
ChildActivationEnd | ActivationStart | ActivationEnd | Scroll;
|