mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
feat(frame): add navigatingTo and navigatedTo events (#9025)
This commit is contained in:
@ -249,6 +249,12 @@ export class FrameBase extends CustomLayoutView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newPage.onNavigatedTo(isBack);
|
newPage.onNavigatedTo(isBack);
|
||||||
|
this.notify({
|
||||||
|
eventName: Page.navigatedToEvent,
|
||||||
|
object: this,
|
||||||
|
isBack,
|
||||||
|
entry,
|
||||||
|
});
|
||||||
|
|
||||||
// Reset executing context after NavigatedTo is raised;
|
// Reset executing context after NavigatedTo is raised;
|
||||||
// we do not want to execute two navigations in parallel in case
|
// we do not want to execute two navigations in parallel in case
|
||||||
@ -417,6 +423,13 @@ export class FrameBase extends CustomLayoutView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
backstackEntry.resolvedPage.onNavigatingTo(backstackEntry.entry.context, isBack, backstackEntry.entry.bindingContext);
|
backstackEntry.resolvedPage.onNavigatingTo(backstackEntry.entry.context, isBack, backstackEntry.entry.bindingContext);
|
||||||
|
this.notify({
|
||||||
|
eventName: Page.navigatingToEvent,
|
||||||
|
object: this,
|
||||||
|
isBack,
|
||||||
|
entry: backstackEntry.entry,
|
||||||
|
fromEntry:this.currentEntry
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public get animated(): boolean {
|
public get animated(): boolean {
|
||||||
|
18
packages/core/ui/frame/index.d.ts
vendored
18
packages/core/ui/frame/index.d.ts
vendored
@ -1,11 +1,17 @@
|
|||||||
import { NavigationType, FrameBase } from './frame-common';
|
import { NavigationType, FrameBase } from './frame-common';
|
||||||
import { Page } from '../page';
|
import { NavigatedData, Page } from '../page';
|
||||||
import { Observable, EventData } from '../../data/observable';
|
import { Observable, EventData } from '../../data/observable';
|
||||||
import { View } from '../core/view';
|
import { View } from '../core/view';
|
||||||
import { Transition } from '../transition';
|
import { Transition } from '../transition';
|
||||||
|
|
||||||
export * from './frame-interfaces';
|
export * from './frame-interfaces';
|
||||||
|
|
||||||
|
export interface NavigationData extends EventData {
|
||||||
|
entry?: NavigationEntry;
|
||||||
|
fromEntry?: NavigationEntry;
|
||||||
|
isBack?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the logical View unit that is responsible for navigation within an application.
|
* Represents the logical View unit that is responsible for navigation within an application.
|
||||||
* Nested frames are supported, enabling hierarchical navigation scenarios.
|
* Nested frames are supported, enabling hierarchical navigation scenarios.
|
||||||
@ -210,6 +216,16 @@ export class Frame extends FrameBase {
|
|||||||
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
||||||
*/
|
*/
|
||||||
on(eventNames: string, callback: (args: EventData) => void, thisArg?: any);
|
on(eventNames: string, callback: (args: EventData) => void, thisArg?: any);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raised when navigation to the page has started.
|
||||||
|
*/
|
||||||
|
public on(event: 'navigatingTo', callback: (args: NavigationData) => void, thisArg?: any);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raised when navigation to the page has finished.
|
||||||
|
*/
|
||||||
|
public on(event: 'navigatedTo', callback: (args: NavigationData) => void, thisArg?: any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user