feat(nav): animation is customizable

fixes #15851
This commit is contained in:
Manu Mtz.-Almeida
2018-10-04 18:05:49 +02:00
parent dc976cc745
commit 24f33730a0
5 changed files with 30 additions and 24 deletions

View File

@ -492,7 +492,7 @@ export class MenuToggle {
} }
export declare interface Nav extends StencilComponents<'IonNav'> {} export declare interface Nav extends StencilComponents<'IonNav'> {}
@Component({ selector: 'ion-nav', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: '<ng-content></ng-content>', inputs: ['swipeGesture', 'animated', 'delegate', 'rootParams', 'root'] }) @Component({ selector: 'ion-nav', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: '<ng-content></ng-content>', inputs: ['swipeGesture', 'animated', 'animation', 'delegate', 'rootParams', 'root'] })
export class Nav { export class Nav {
ionNavWillLoad: EventEmitter<CustomEvent>; ionNavWillLoad: EventEmitter<CustomEvent>;
ionNavWillChange: EventEmitter<CustomEvent>; ionNavWillChange: EventEmitter<CustomEvent>;
@ -501,7 +501,7 @@ export class Nav {
constructor(r: ElementRef) { constructor(r: ElementRef) {
const el = r.nativeElement; const el = r.nativeElement;
proxyMethods(this, el, ['push', 'insert', 'insertPages', 'pop', 'popTo', 'popToRoot', 'removeIndex', 'setRoot', 'setPages', 'setRouteId', 'getRouteId', 'getActive', 'getByIndex', 'canGoBack', 'getPrevious']); proxyMethods(this, el, ['push', 'insert', 'insertPages', 'pop', 'popTo', 'popToRoot', 'removeIndex', 'setRoot', 'setPages', 'setRouteId', 'getRouteId', 'getActive', 'getByIndex', 'canGoBack', 'getPrevious']);
proxyInputs(this, el, ['swipeGesture', 'animated', 'delegate', 'rootParams', 'root']); proxyInputs(this, el, ['swipeGesture', 'animated', 'animation', 'delegate', 'rootParams', 'root']);
proxyOutputs(this, el, ['ionNavWillLoad', 'ionNavWillChange', 'ionNavDidChange']); proxyOutputs(this, el, ['ionNavWillLoad', 'ionNavWillChange', 'ionNavDidChange']);
} }
} }

View File

@ -2782,6 +2782,7 @@ export namespace Components {
* If the nav should animate the components or not * If the nav should animate the components or not
*/ */
'animated': boolean; 'animated': boolean;
'animation'?: AnimationBuilder;
/** /**
* Returns true or false if the current view can go back * Returns true or false if the current view can go back
*/ */
@ -2855,6 +2856,7 @@ export namespace Components {
* If the nav should animate the components or not * If the nav should animate the components or not
*/ */
'animated'?: boolean; 'animated'?: boolean;
'animation'?: AnimationBuilder;
'delegate'?: FrameworkDelegate; 'delegate'?: FrameworkDelegate;
/** /**
* Event fired when the nav has changed components * Event fired when the nav has changed components
@ -3619,7 +3621,7 @@ export namespace Components {
interface IonRouterOutlet { interface IonRouterOutlet {
'animated': boolean; 'animated': boolean;
'animationBuilder'?: AnimationBuilder; 'animation'?: AnimationBuilder;
'commit': (enteringEl: HTMLElement, leavingEl: HTMLElement | undefined, opts?: RouterOutletOptions | undefined) => Promise<boolean>; 'commit': (enteringEl: HTMLElement, leavingEl: HTMLElement | undefined, opts?: RouterOutletOptions | undefined) => Promise<boolean>;
'delegate'?: FrameworkDelegate; 'delegate'?: FrameworkDelegate;
/** /**
@ -3634,7 +3636,7 @@ export namespace Components {
} }
interface IonRouterOutletAttributes extends StencilHTMLAttributes { interface IonRouterOutletAttributes extends StencilHTMLAttributes {
'animated'?: boolean; 'animated'?: boolean;
'animationBuilder'?: AnimationBuilder; 'animation'?: AnimationBuilder;
'delegate'?: FrameworkDelegate; 'delegate'?: FrameworkDelegate;
'onIonNavDidChange'?: (event: CustomEvent<void>) => void; 'onIonNavDidChange'?: (event: CustomEvent<void>) => void;
'onIonNavWillChange'?: (event: CustomEvent<void>) => void; 'onIonNavWillChange'?: (event: CustomEvent<void>) => void;

View File

@ -1,7 +1,7 @@
import { Build, Component, Element, Event, EventEmitter, Method, Prop, QueueApi, Watch } from '@stencil/core'; import { Build, Component, Element, Event, EventEmitter, Method, Prop, QueueApi, Watch } from '@stencil/core';
import { ViewLifecycle } from '../..'; import { ViewLifecycle } from '../..';
import { Animation, ComponentProps, Config, FrameworkDelegate, Gesture, GestureDetail, Mode, NavComponent, NavOptions, NavOutlet, NavResult, RouteID, RouteWrite, TransitionDoneFn, TransitionInstruction, ViewController } from '../../interface'; import { Animation, AnimationBuilder, ComponentProps, Config, FrameworkDelegate, Gesture, GestureDetail, Mode, NavComponent, NavOptions, NavOutlet, NavResult, RouteID, RouteWrite, TransitionDoneFn, TransitionInstruction, ViewController } from '../../interface';
import { assert } from '../../utils/helpers'; import { assert } from '../../utils/helpers';
import { TransitionOptions, lifecycle, setPageHidden, transition } from '../../utils/transition'; import { TransitionOptions, lifecycle, setPageHidden, transition } from '../../utils/transition';
@ -27,11 +27,8 @@ export class Nav implements NavOutlet {
@Element() el!: HTMLElement; @Element() el!: HTMLElement;
@Prop({ context: 'queue' }) queue!: QueueApi; @Prop({ context: 'queue' }) queue!: QueueApi;
@Prop({ context: 'config' }) config!: Config; @Prop({ context: 'config' }) config!: Config;
@Prop({ context: 'window' }) win!: Window; @Prop({ context: 'window' }) win!: Window;
@Prop({ connect: 'ion-animation-controller' }) animationCtrl!: HTMLIonAnimationControllerElement; @Prop({ connect: 'ion-animation-controller' }) animationCtrl!: HTMLIonAnimationControllerElement;
/** /**
@ -49,6 +46,7 @@ export class Nav implements NavOutlet {
* If the nav should animate the components or not * If the nav should animate the components or not
*/ */
@Prop() animated = true; @Prop() animated = true;
@Prop() animation?: AnimationBuilder;
/** @hidden */ /** @hidden */
@Prop() delegate?: FrameworkDelegate; @Prop() delegate?: FrameworkDelegate;
@ -795,6 +793,7 @@ export class Nav implements NavOutlet {
queue: this.queue, queue: this.queue,
window: this.win, window: this.win,
baseEl: this.el, baseEl: this.el,
animationBuilder: this.animation || opts.animationBuilder || this.config.get('navAnimation'),
progressCallback, progressCallback,
animated, animated,

View File

@ -25,7 +25,7 @@ export class RouterOutlet implements ComponentInterface, NavOutlet {
@Prop({ context: 'queue' }) queue!: QueueApi; @Prop({ context: 'queue' }) queue!: QueueApi;
@Prop() animated = true; @Prop() animated = true;
@Prop() animationBuilder?: AnimationBuilder; @Prop() animation?: AnimationBuilder;
@Prop() delegate?: FrameworkDelegate; @Prop() delegate?: FrameworkDelegate;
@Event() ionNavWillLoad!: EventEmitter<void>; @Event() ionNavWillLoad!: EventEmitter<void>;
@ -124,11 +124,14 @@ export class RouterOutlet implements ComponentInterface, NavOutlet {
const { mode, queue, animationCtrl, win, el } = this; const { mode, queue, animationCtrl, win, el } = this;
const animated = this.animated && this.config.getBoolean('animated', true); const animated = this.animated && this.config.getBoolean('animated', true);
const animationBuilder = this.animation || opts.animationBuilder || this.config.get('navAnimation');
await transition({ await transition({
mode, mode,
queue, queue,
animated, animated,
animationCtrl, animationCtrl,
animationBuilder,
window: win, window: win,
enteringEl, enteringEl,
leavingEl, leavingEl,

View File

@ -1,4 +1,4 @@
import { Mode } from '../interface'; import { AnimationBuilder, Mode } from '../interface';
export interface IonicConfig { export interface IonicConfig {
/** /**
@ -33,21 +33,23 @@ export interface IonicConfig {
tabbarLayout?: string; tabbarLayout?: string;
tabbarHighlight?: boolean; tabbarHighlight?: boolean;
actionSheetEnter?: string; navAnimation?: AnimationBuilder;
alertEnter?: string;
loadingEnter?: string;
modalEnter?: string;
popoverEnter?: string;
toastEnter?: string;
pickerEnter?: string;
actionSheetLeave?: string; actionSheetEnter?: AnimationBuilder;
alertLeave?: string; alertEnter?: AnimationBuilder;
loadingLeave?: string; loadingEnter?: AnimationBuilder;
modalLeave?: string; modalEnter?: AnimationBuilder;
popoverLeave?: string; popoverEnter?: AnimationBuilder;
toastLeave?: string; toastEnter?: AnimationBuilder;
pickerLeave?: string; pickerEnter?: AnimationBuilder;
actionSheetLeave?: AnimationBuilder;
alertLeave?: AnimationBuilder;
loadingLeave?: AnimationBuilder;
modalLeave?: AnimationBuilder;
popoverLeave?: AnimationBuilder;
toastLeave?: AnimationBuilder;
pickerLeave?: AnimationBuilder;
_forceStatusbarPadding?: boolean; _forceStatusbarPadding?: boolean;
} }