mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(navigation): unbroke the build
This commit is contained in:
@ -1,12 +1,12 @@
|
|||||||
import { Component, Method } from '@stencil/core';
|
import { Component, Method } from '@stencil/core';
|
||||||
import { Animation, AnimationBuilder } from './animation-interface';
|
import { Animation, AnimationBuilder, AnimationController } from './animation-interface';
|
||||||
import { Animator } from './animator';
|
import { Animator } from './animator';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-animation-controller'
|
tag: 'ion-animation-controller'
|
||||||
})
|
})
|
||||||
export class AnimationController {
|
export class AnimationControllerImpl implements AnimationController {
|
||||||
|
|
||||||
@Method()
|
@Method()
|
||||||
create(animationBuilder?: AnimationBuilder, baseElm?: any): Promise<Animation> {
|
create(animationBuilder?: AnimationBuilder, baseElm?: any): Promise<Animation> {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
export interface AnimationController {
|
||||||
|
create(animationBuilder?: AnimationBuilder, baseElm?: any): Promise<Animation>;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Animation {
|
export interface Animation {
|
||||||
new (): Animation;
|
new (): Animation;
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { Component, Element, Method, Prop } from '@stencil/core';
|
import { Component, Element, Method, Prop } from '@stencil/core';
|
||||||
import { Transition } from '../../navigation/transitions/transition';
|
import { FrameworkDelegate, NavController, NavOptions, ViewController } from '../../navigation/nav-interfaces';
|
||||||
import { NavController } from '../../navigation/nav-controller';
|
|
||||||
import { getNextNavId, getViews, pop, push, setRoot } from '../../navigation/nav-controller-functions';
|
import { getNextNavId, getViews, pop, push, setRoot } from '../../navigation/nav-controller-functions';
|
||||||
import { NavOptions } from '../../navigation/nav-utils';
|
|
||||||
import { ViewController } from '../../navigation/view-controller';
|
|
||||||
|
|
||||||
import { FrameworkDelegate } from '../../navigation/framework-delegate';
|
|
||||||
import { delegate as defaultStencilDelegate } from '../../navigation/stencil-framework-delegate';
|
import { delegate as defaultStencilDelegate } from '../../navigation/stencil-framework-delegate';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -21,7 +17,7 @@ export class Nav implements NavController {
|
|||||||
transitionId?: number;
|
transitionId?: number;
|
||||||
isViewInitialized?: boolean;
|
isViewInitialized?: boolean;
|
||||||
isPortal: boolean;
|
isPortal: boolean;
|
||||||
swipeToGoBackTransition: Transition;
|
swipeToGoBackTransition: any; // TODO Transition
|
||||||
childNavs?: NavController[];
|
childNavs?: NavController[];
|
||||||
|
|
||||||
@Prop() root: any;
|
@Prop() root: any;
|
||||||
|
3
packages/core/src/index.d.ts
vendored
3
packages/core/src/index.d.ts
vendored
@ -1,5 +1,4 @@
|
|||||||
import { AnimationController } from './components/animation-controller/animation-controller';
|
import { Animation, AnimationBuilder, AnimationController } from './components/animation-controller/animation-interface';
|
||||||
import { Animation, AnimationBuilder } from './components/animation-controller/animation-interface';
|
|
||||||
import { ActionSheet, ActionSheetButton, ActionSheetEvent, ActionSheetOptions } from './components/action-sheet/action-sheet';
|
import { ActionSheet, ActionSheetButton, ActionSheetEvent, ActionSheetOptions } from './components/action-sheet/action-sheet';
|
||||||
import { ActionSheetController } from './components/action-sheet-controller/action-sheet-controller';
|
import { ActionSheetController } from './components/action-sheet-controller/action-sheet-controller';
|
||||||
import { Backdrop } from './components/backdrop/backdrop'
|
import { Backdrop } from './components/backdrop/backdrop'
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { NavController } from './nav-controller';
|
|
||||||
import { ViewController } from './view-controller';
|
|
||||||
|
|
||||||
export interface FrameworkDelegate {
|
|
||||||
attachViewToDom(navController: NavController, enteringView: ViewController): Promise<any>;
|
|
||||||
removeViewFromDom(navController: NavController, leavingView: ViewController): Promise<any>;
|
|
||||||
destroy(viewController: ViewController): Promise<any>;
|
|
||||||
}
|
|
@ -1,6 +1,13 @@
|
|||||||
import { AnimationOptions } from '../animations/interfaces';
|
import { AnimationOptions } from '../components/animation-controller/animation-interface';
|
||||||
import { FrameworkDelegate } from './framework-delegate';
|
import {
|
||||||
import { NavController } from './nav-controller';
|
ComponentDataPair,
|
||||||
|
FrameworkDelegate,
|
||||||
|
NavController,
|
||||||
|
NavOptions,
|
||||||
|
NavResult,
|
||||||
|
TransitionInstruction,
|
||||||
|
ViewController
|
||||||
|
} from './nav-interfaces';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DIRECTION_BACK,
|
DIRECTION_BACK,
|
||||||
@ -8,26 +15,17 @@ import {
|
|||||||
STATE_ATTACHED,
|
STATE_ATTACHED,
|
||||||
STATE_DESTROYED,
|
STATE_DESTROYED,
|
||||||
STATE_INITIALIZED,
|
STATE_INITIALIZED,
|
||||||
ComponentDataPair,
|
|
||||||
NavOptions,
|
|
||||||
NavResult,
|
|
||||||
TransitionInstruction,
|
|
||||||
isViewController,
|
isViewController,
|
||||||
setZIndex,
|
setZIndex,
|
||||||
toggleHidden
|
toggleHidden
|
||||||
} from './nav-utils';
|
} from './nav-utils';
|
||||||
|
|
||||||
|
|
||||||
import { ViewController } from './view-controller';
|
|
||||||
import { ViewControllerImpl } from './view-controller-impl';
|
import { ViewControllerImpl } from './view-controller-impl';
|
||||||
|
|
||||||
import { assert, isDef, isNumber } from '../utils/helpers';
|
import { assert, isDef, isNumber } from '../utils/helpers';
|
||||||
import { NAV_ID_START, VIEW_ID_START } from '../utils/ids';
|
import { NAV_ID_START, VIEW_ID_START } from '../utils/ids';
|
||||||
|
|
||||||
import { DanTransition } from './transitions/dan-transition';
|
|
||||||
import { Transition } from './transitions/transition';
|
|
||||||
import { destroy, getRootTransitionId, nextId } from './transitions/transition-controller';
|
|
||||||
|
|
||||||
const queueMap = new Map<number, TransitionInstruction[]>();
|
const queueMap = new Map<number, TransitionInstruction[]>();
|
||||||
|
|
||||||
// public api
|
// public api
|
||||||
@ -302,7 +300,8 @@ export function loadViewAndTransition(nav: NavController, enteringView: ViewCont
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
nav.transitionId = getRootTransitionId(nav) || nextId();
|
// TODO - transitionId
|
||||||
|
nav.transitionId = 1; //getRootTransitionId(nav) || nextId();
|
||||||
|
|
||||||
// create the transition options
|
// create the transition options
|
||||||
const animationOpts: AnimationOptions = {
|
const animationOpts: AnimationOptions = {
|
||||||
@ -314,7 +313,10 @@ export function loadViewAndTransition(nav: NavController, enteringView: ViewCont
|
|||||||
ev: ti.opts.event,
|
ev: ti.opts.event,
|
||||||
};
|
};
|
||||||
|
|
||||||
const transition = new DanTransition(enteringView, leavingView, animationOpts);
|
// TODO - need transition here
|
||||||
|
const transition: any = {
|
||||||
|
opts: animationOpts
|
||||||
|
};// new DanTransition(enteringView, leavingView, animationOpts);
|
||||||
|
|
||||||
//const transition = getTransition(stateData.transitionId, enteringView, animationOpts);
|
//const transition = getTransition(stateData.transitionId, enteringView, animationOpts);
|
||||||
|
|
||||||
@ -342,11 +344,13 @@ export function loadViewAndTransition(nav: NavController, enteringView: ViewCont
|
|||||||
}
|
}
|
||||||
return promiseToReturn;
|
return promiseToReturn;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return executeAsyncTransition(nav, transition, enteringView, leavingView, ti.opts);
|
// TODO - get the shouldAnimate param from the config
|
||||||
|
return executeAsyncTransition(nav, transition, enteringView, leavingView, ti.opts, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function executeAsyncTransition(nav: NavController, transition: Transition, enteringView: ViewController, leavingView: ViewController, opts: NavOptions): Promise<NavResult> {
|
// TODO - transition type
|
||||||
|
export function executeAsyncTransition(nav: NavController, transition: any, enteringView: ViewController, leavingView: ViewController, opts: NavOptions, configShouldAnimate: boolean): Promise<NavResult> {
|
||||||
assert(nav.transitioning, 'must be transitioning');
|
assert(nav.transitioning, 'must be transitioning');
|
||||||
nav.transitionId = null;
|
nav.transitionId = null;
|
||||||
setZIndex(nav.isPortal, enteringView, leavingView, opts.direction);
|
setZIndex(nav.isPortal, enteringView, leavingView, opts.direction);
|
||||||
@ -364,7 +368,7 @@ export function executeAsyncTransition(nav: NavController, transition: Transitio
|
|||||||
transition.init()
|
transition.init()
|
||||||
|
|
||||||
const shouldNotAnimate = (!nav.isViewInitialized && nav.views.length === 1) && !nav.isPortal;
|
const shouldNotAnimate = (!nav.isViewInitialized && nav.views.length === 1) && !nav.isPortal;
|
||||||
if (Ionic.config.get('animate') === false || shouldNotAnimate) {
|
if (configShouldAnimate === false || shouldNotAnimate) {
|
||||||
opts.animate = false;
|
opts.animate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +416,8 @@ export function executeAsyncTransition(nav: NavController, transition: Transitio
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transitionFinish(nav: NavController, transition: Transition, opts: NavOptions): NavResult {
|
// TODO - transition type
|
||||||
|
export function transitionFinish(nav: NavController, transition: any, opts: NavOptions): NavResult {
|
||||||
if (transition.hasCompleted) {
|
if (transition.hasCompleted) {
|
||||||
transition.enteringView && transition.enteringView.didEnter();
|
transition.enteringView && transition.enteringView.didEnter();
|
||||||
transition.leavingView && transition.leavingView.didLeave();
|
transition.leavingView && transition.leavingView.didLeave();
|
||||||
@ -423,7 +428,9 @@ export function transitionFinish(nav: NavController, transition: Transition, opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (transition.isRoot()) {
|
if (transition.isRoot()) {
|
||||||
destroy(transition.transitionId);
|
|
||||||
|
// TODO - destroy the transition object
|
||||||
|
//destroy(transition.transitionId);
|
||||||
|
|
||||||
// TODO - enable app
|
// TODO - enable app
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import { ViewController } from './view-controller';
|
|
||||||
import { Transition } from './transitions/transition';
|
|
||||||
|
|
||||||
export interface NavController {
|
|
||||||
id: number;
|
|
||||||
element: HTMLElement;
|
|
||||||
views?: ViewController[];
|
|
||||||
transitioning?: boolean;
|
|
||||||
destroyed?: boolean;
|
|
||||||
transitionId?: number;
|
|
||||||
isViewInitialized?: boolean;
|
|
||||||
isPortal?: boolean;
|
|
||||||
swipeToGoBackTransition?: Transition;
|
|
||||||
getParent(): NavController;
|
|
||||||
childNavs?: NavController[]; // TODO - make nav container
|
|
||||||
}
|
|
97
packages/core/src/navigation/nav-interfaces.d.ts
vendored
Normal file
97
packages/core/src/navigation/nav-interfaces.d.ts
vendored
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
export interface FrameworkDelegate {
|
||||||
|
attachViewToDom(navController: NavController, enteringView: ViewController): Promise<any>;
|
||||||
|
removeViewFromDom(navController: NavController, leavingView: ViewController): Promise<any>;
|
||||||
|
destroy(viewController: ViewController): Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NavController {
|
||||||
|
id: number;
|
||||||
|
element: HTMLElement;
|
||||||
|
views?: ViewController[];
|
||||||
|
transitioning?: boolean;
|
||||||
|
destroyed?: boolean;
|
||||||
|
transitionId?: number;
|
||||||
|
isViewInitialized?: boolean;
|
||||||
|
isPortal?: boolean;
|
||||||
|
swipeToGoBackTransition?: any; // TODO Transition
|
||||||
|
getParent(): NavController;
|
||||||
|
childNavs?: NavController[]; // TODO - make nav container
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ViewController {
|
||||||
|
id: string;
|
||||||
|
component: any;
|
||||||
|
data: any;
|
||||||
|
element: HTMLElement;
|
||||||
|
instance: any;
|
||||||
|
state: number;
|
||||||
|
nav: NavController;
|
||||||
|
frameworkDelegate: FrameworkDelegate;
|
||||||
|
dismissProxy?: any;
|
||||||
|
|
||||||
|
// life cycle events
|
||||||
|
willLeave(unload: boolean): void;
|
||||||
|
didLeave(): void;
|
||||||
|
willEnter(): void;
|
||||||
|
didEnter(): void;
|
||||||
|
willLoad(): void;
|
||||||
|
didLoad(): void;
|
||||||
|
willUnload():void;
|
||||||
|
|
||||||
|
destroy(): Promise<any>;
|
||||||
|
getTransitionName(direction: string): string;
|
||||||
|
onDidDismiss: (data: any, role: string) => void;
|
||||||
|
onWillDismiss: (data: any, role: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NavResult {
|
||||||
|
hasCompleted: boolean;
|
||||||
|
requiresTransition: boolean;
|
||||||
|
enteringName?: string;
|
||||||
|
leavingName?: string;
|
||||||
|
direction?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NavOptions {
|
||||||
|
animate?: boolean;
|
||||||
|
animation?: string;
|
||||||
|
direction?: string;
|
||||||
|
duration?: number;
|
||||||
|
easing?: string;
|
||||||
|
id?: string;
|
||||||
|
keyboardClose?: boolean;
|
||||||
|
progressAnimation?: boolean;
|
||||||
|
disableApp?: boolean;
|
||||||
|
event?: any;
|
||||||
|
updateUrl?: boolean;
|
||||||
|
isNavRoot?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TransitionInstruction {
|
||||||
|
opts: NavOptions;
|
||||||
|
insertStart?: number;
|
||||||
|
insertViews?: any[];
|
||||||
|
removeView?: any; // TODO make VC
|
||||||
|
removeStart?: number;
|
||||||
|
removeCount?: number;
|
||||||
|
resolve?: (hasCompleted: boolean) => void;
|
||||||
|
reject?: (rejectReason: Error) => void;
|
||||||
|
done?: Function;
|
||||||
|
leavingRequiresTransition?: boolean;
|
||||||
|
enteringRequiresTransition?: boolean;
|
||||||
|
requiresTransition?: boolean;
|
||||||
|
id?: number;
|
||||||
|
nav?: NavController;
|
||||||
|
delegate?: FrameworkDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NavResult {
|
||||||
|
hasCompleted: boolean;
|
||||||
|
requiresTransition: boolean;
|
||||||
|
direction?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ComponentDataPair {
|
||||||
|
page: any;
|
||||||
|
params: any;
|
||||||
|
}
|
@ -1,7 +1,4 @@
|
|||||||
import { FrameworkDelegate } from './framework-delegate';
|
import { ViewController } from './nav-interfaces';
|
||||||
import { NavController } from './nav-controller';
|
|
||||||
import { ViewController } from './view-controller';
|
|
||||||
import { Transition } from './transitions/transition';
|
|
||||||
|
|
||||||
export const STATE_NEW = 1;
|
export const STATE_NEW = 1;
|
||||||
export const STATE_INITIALIZED = 2;
|
export const STATE_INITIALIZED = 2;
|
||||||
@ -17,73 +14,12 @@ export const DIRECTION_SWITCH = 'switch';
|
|||||||
export const NAV = 'nav';
|
export const NAV = 'nav';
|
||||||
export const TABS = 'tabs';
|
export const TABS = 'tabs';
|
||||||
|
|
||||||
export interface NavResult {
|
|
||||||
hasCompleted: boolean;
|
|
||||||
requiresTransition: boolean;
|
|
||||||
enteringName?: string;
|
|
||||||
leavingName?: string;
|
|
||||||
direction?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavControllerData {
|
|
||||||
transitioning?: boolean;
|
|
||||||
destroyed?: boolean;
|
|
||||||
views?: ViewController[];
|
|
||||||
childNavs?: NavController[];
|
|
||||||
isPortal?: boolean;
|
|
||||||
isViewInitialized?: boolean;
|
|
||||||
transitionId?: number;
|
|
||||||
swipeToGoBackTransition?: Transition;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavOptions {
|
|
||||||
animate?: boolean;
|
|
||||||
animation?: string;
|
|
||||||
direction?: string;
|
|
||||||
duration?: number;
|
|
||||||
easing?: string;
|
|
||||||
id?: string;
|
|
||||||
keyboardClose?: boolean;
|
|
||||||
progressAnimation?: boolean;
|
|
||||||
disableApp?: boolean;
|
|
||||||
event?: any;
|
|
||||||
updateUrl?: boolean;
|
|
||||||
isNavRoot?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransitionInstruction {
|
|
||||||
opts: NavOptions;
|
|
||||||
insertStart?: number;
|
|
||||||
insertViews?: any[];
|
|
||||||
removeView?: any; // TODO make VC
|
|
||||||
removeStart?: number;
|
|
||||||
removeCount?: number;
|
|
||||||
resolve?: (hasCompleted: boolean) => void;
|
|
||||||
reject?: (rejectReason: Error) => void;
|
|
||||||
done?: Function;
|
|
||||||
leavingRequiresTransition?: boolean;
|
|
||||||
enteringRequiresTransition?: boolean;
|
|
||||||
requiresTransition?: boolean;
|
|
||||||
id?: number;
|
|
||||||
nav?: NavController;
|
|
||||||
delegate?: FrameworkDelegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NavResult {
|
|
||||||
hasCompleted: boolean;
|
|
||||||
requiresTransition: boolean;
|
|
||||||
direction?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isViewController(object: any): boolean {
|
export function isViewController(object: any): boolean {
|
||||||
return !!(object && object.didLoad && object.willUnload);
|
return !!(object && object.didLoad && object.willUnload);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ComponentDataPair {
|
|
||||||
page: any;
|
|
||||||
params: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setZIndex(_isPortal: boolean, _enteringView: ViewController, _leavingView: ViewController, _direction: string) {
|
export function setZIndex(_isPortal: boolean, _enteringView: ViewController, _leavingView: ViewController, _direction: string) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { NavController } from './nav-controller';
|
import { NavController, ViewController } from './nav-interfaces';
|
||||||
import { ViewController } from './view-controller';
|
|
||||||
|
|
||||||
export function attachViewToDom(nav: NavController, enteringView: ViewController): Promise<any> {
|
export function attachViewToDom(nav: NavController, enteringView: ViewController): Promise<any> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import { Transition } from './transition';
|
|
||||||
import { ViewController } from '../view-controller';
|
|
||||||
|
|
||||||
import { Animation } from '../../animations/animation';
|
|
||||||
import { AnimationOptions } from '../../animations/interfaces';
|
|
||||||
|
|
||||||
export class DanTransition extends Transition {
|
|
||||||
constructor(public enteringView: ViewController, public leavingView: ViewController, opts: AnimationOptions = {}) {
|
|
||||||
super(enteringView, leavingView, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
init() {
|
|
||||||
super.init();
|
|
||||||
|
|
||||||
const enteringAnimation = new Animation(this.enteringView.element);
|
|
||||||
enteringAnimation.fromTo('display', '', '');
|
|
||||||
this.add(enteringAnimation);
|
|
||||||
|
|
||||||
if (this.leavingView) {
|
|
||||||
const leavingAnimation = new Animation(this.leavingView.element);
|
|
||||||
leavingAnimation.fromTo('display', '', 'none');
|
|
||||||
this.add(leavingAnimation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
import { Animation } from '../../animations/animation';
|
|
||||||
import { Transition } from './transition';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hidden
|
|
||||||
*/
|
|
||||||
export class PageTransition extends Transition {
|
|
||||||
enteringPage: Animation;
|
|
||||||
|
|
||||||
init() {
|
|
||||||
if (this.enteringView) {
|
|
||||||
this.enteringPage = new Animation(this.enteringView.element);
|
|
||||||
this.add(this.enteringPage.beforeAddClass('show-page'));
|
|
||||||
|
|
||||||
// Resize content before transition starts
|
|
||||||
this.beforeAddRead(() => {
|
|
||||||
// TODO this.enteringView.readReady.emit();
|
|
||||||
});
|
|
||||||
this.beforeAddWrite(() => {
|
|
||||||
// TODO this.enteringView.writeReady.emit();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy() {
|
|
||||||
super.destroy();
|
|
||||||
this.enteringPage && this.enteringPage.destroy();
|
|
||||||
this.enteringPage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
import { NavController } from '../nav-controller';
|
|
||||||
import { ViewController } from '../view-controller';
|
|
||||||
import { AnimationOptions } from '../../animations/interfaces';
|
|
||||||
|
|
||||||
import { Transition } from './transition';
|
|
||||||
import { isDef } from '../../utils/helpers';
|
|
||||||
|
|
||||||
export function getRootTransitionId(nav: NavController): number {
|
|
||||||
nav = nav.getParent();
|
|
||||||
while (nav) {
|
|
||||||
const transitionId = nav.transitionId;
|
|
||||||
if (isDef(transitionId)) {
|
|
||||||
return transitionId;
|
|
||||||
}
|
|
||||||
nav = nav.getParent();
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function nextId() {
|
|
||||||
return transitionIds++;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function destroy(transitionId: number) {
|
|
||||||
const transition = transitions.get(transitionId);
|
|
||||||
if (transition) {
|
|
||||||
transition.destroy();
|
|
||||||
transitions.delete(transitionId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTransition(transitionId: number, viewController: ViewController, opts: AnimationOptions): Transition {
|
|
||||||
const TransitionConstructor: any = Ionic.config.get(opts.animation) || Ionic.config.get('ios-transition');
|
|
||||||
|
|
||||||
const transition = new TransitionConstructor(viewController.element) as Transition;
|
|
||||||
transition.transitionId = transitionId;
|
|
||||||
|
|
||||||
const rootTransition = transitions.get(transitionId);
|
|
||||||
if (rootTransition) {
|
|
||||||
rootTransition.add(transition);
|
|
||||||
} else {
|
|
||||||
transitions.set(transitionId, transition);
|
|
||||||
}
|
|
||||||
|
|
||||||
return transition;
|
|
||||||
}
|
|
||||||
|
|
||||||
let transitionIds = 0;
|
|
||||||
let transitions = new Map<number, any>();
|
|
@ -1,35 +0,0 @@
|
|||||||
import { Animation } from '../../animations/animation';
|
|
||||||
import { AnimationOptions } from '../../animations/interfaces';
|
|
||||||
|
|
||||||
import { ViewController } from '../view-controller';
|
|
||||||
|
|
||||||
export class Transition extends Animation {
|
|
||||||
|
|
||||||
private transitionStart: Function;
|
|
||||||
parent: Transition;
|
|
||||||
transitionId: number;
|
|
||||||
|
|
||||||
constructor(public enteringView: ViewController, public leavingView: ViewController, public opts: AnimationOptions) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
init() {
|
|
||||||
}
|
|
||||||
|
|
||||||
registerStart(transitionStart: Function) {
|
|
||||||
this.transitionStart = transitionStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
this.transitionStart && this.transitionStart();
|
|
||||||
this.transitionStart = null;
|
|
||||||
|
|
||||||
// bubble up start
|
|
||||||
this.parent && this.parent.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy() {
|
|
||||||
super.destroy();
|
|
||||||
this.parent = this.transitionStart = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,8 @@
|
|||||||
|
import { FrameworkDelegate, NavController, ViewController } from './nav-interfaces';
|
||||||
import { STATE_ATTACHED, STATE_DESTROYED, STATE_INITIALIZED } from './nav-utils';
|
import { STATE_ATTACHED, STATE_DESTROYED, STATE_INITIALIZED } from './nav-utils';
|
||||||
|
|
||||||
import { NavController } from './nav-controller';
|
|
||||||
import { ViewController } from './view-controller';
|
|
||||||
|
|
||||||
import { assert } from '../utils/helpers';
|
import { assert } from '../utils/helpers';
|
||||||
|
|
||||||
import { FrameworkDelegate } from './framework-delegate';
|
|
||||||
|
|
||||||
export class ViewControllerImpl implements ViewController {
|
export class ViewControllerImpl implements ViewController {
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
import { NavController } from './nav-controller';
|
|
||||||
import { FrameworkDelegate } from './framework-delegate';
|
|
||||||
|
|
||||||
export interface ViewController {
|
|
||||||
id: string;
|
|
||||||
component: any;
|
|
||||||
data: any;
|
|
||||||
element: HTMLElement;
|
|
||||||
instance: any;
|
|
||||||
state: number;
|
|
||||||
nav: NavController;
|
|
||||||
frameworkDelegate: FrameworkDelegate;
|
|
||||||
dismissProxy?: any;
|
|
||||||
|
|
||||||
// life cycle events
|
|
||||||
willLeave(unload: boolean): void;
|
|
||||||
didLeave(): void;
|
|
||||||
willEnter(): void;
|
|
||||||
didEnter(): void;
|
|
||||||
willLoad(): void;
|
|
||||||
didLoad(): void;
|
|
||||||
willUnload():void;
|
|
||||||
|
|
||||||
destroy(): Promise<any>;
|
|
||||||
getTransitionName(direction: string): string;
|
|
||||||
onDidDismiss: (data: any, role: string) => void;
|
|
||||||
onWillDismiss: (data: any, role: string) => void;
|
|
||||||
}
|
|
Reference in New Issue
Block a user