Skip to content

Commit

Permalink
refactor(all): cosmetic changes + app.resize as event emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Feb 28, 2017
1 parent f577e54 commit be0b6a8
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 119 deletions.
4 changes: 2 additions & 2 deletions src/components/action-sheet/action-sheet-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class ActionSheetCmp {
ionViewDidEnter() {
this._plt.focusOutActiveElement();

let focusableEle = this._elementRef.nativeElement.querySelector('button');
const focusableEle = this._elementRef.nativeElement.querySelector('button');
if (focusableEle) {
focusableEle.focus();
}
Expand All @@ -144,7 +144,7 @@ export class ActionSheetCmp {
}

click(button: any) {
if (! this.enabled ) {
if (!this.enabled) {
return;
}

Expand Down
36 changes: 18 additions & 18 deletions src/components/action-sheet/action-sheet-transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Transition } from '../../transitions/transition';

export class ActionSheetSlideIn extends Transition {
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
const ele = this.enteringView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));

backdrop.fromTo('opacity', 0.01, 0.4);
wrapper.fromTo('translateY', '100%', '0%');
Expand All @@ -18,9 +18,9 @@ export class ActionSheetSlideIn extends Transition {

export class ActionSheetSlideOut extends Transition {
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
const ele = this.leavingView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));

backdrop.fromTo('opacity', 0.4, 0);
wrapper.fromTo('translateY', '0%', '100%');
Expand All @@ -32,9 +32,9 @@ export class ActionSheetSlideOut extends Transition {

export class ActionSheetMdSlideIn extends Transition {
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
const ele = this.enteringView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));

backdrop.fromTo('opacity', 0.01, 0.26);
wrapper.fromTo('translateY', '100%', '0%');
Expand All @@ -46,9 +46,9 @@ export class ActionSheetMdSlideIn extends Transition {

export class ActionSheetMdSlideOut extends Transition {
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
const ele = this.leavingView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));

backdrop.fromTo('opacity', 0.26, 0);
wrapper.fromTo('translateY', '0%', '100%');
Expand All @@ -60,9 +60,9 @@ export class ActionSheetMdSlideOut extends Transition {

export class ActionSheetWpSlideIn extends Transition {
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
const ele = this.enteringView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));

backdrop.fromTo('opacity', 0.01, 0.16);
wrapper.fromTo('translateY', '100%', '0%');
Expand All @@ -74,9 +74,9 @@ export class ActionSheetWpSlideIn extends Transition {

export class ActionSheetWpSlideOut extends Transition {
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
const ele = this.leavingView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));

backdrop.fromTo('opacity', 0.1, 0);
wrapper.fromTo('translateY', '0%', '100%');
Expand Down
36 changes: 18 additions & 18 deletions src/components/alert/alert-transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { Transition } from '../../transitions/transition';
*/
export class AlertPopIn extends Transition {
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
const ele = this.enteringView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));

wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.1, 1);
backdrop.fromTo('opacity', 0.01, 0.3);
Expand All @@ -25,9 +25,9 @@ export class AlertPopIn extends Transition {

export class AlertPopOut extends Transition {
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
const ele = this.leavingView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));

wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 0.9);
backdrop.fromTo('opacity', 0.3, 0);
Expand All @@ -43,9 +43,9 @@ export class AlertPopOut extends Transition {

export class AlertMdPopIn extends Transition {
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
const ele = this.enteringView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));

wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.1, 1);
backdrop.fromTo('opacity', 0.01, 0.5);
Expand All @@ -61,9 +61,9 @@ export class AlertMdPopIn extends Transition {

export class AlertMdPopOut extends Transition {
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
const ele = this.leavingView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));

wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 0.9);
backdrop.fromTo('opacity', 0.5, 0);
Expand All @@ -79,9 +79,9 @@ export class AlertMdPopOut extends Transition {

export class AlertWpPopIn extends Transition {
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
const ele = this.enteringView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));

wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.3, 1);
backdrop.fromTo('opacity', 0.01, 0.5);
Expand All @@ -97,9 +97,9 @@ export class AlertWpPopIn extends Transition {

export class AlertWpPopOut extends Transition {
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
let wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
const ele = this.leavingView.pageRef().nativeElement;
const backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
const wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));

wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 1.3);
backdrop.fromTo('opacity', 0.5, 0);
Expand Down
15 changes: 1 addition & 14 deletions src/components/app/app-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ export const AppRootToken = new OpaqueToken('USERROOT');
export class IonicApp extends Ion implements OnInit {
private _stopScrollPlugin: any;
private _tmr: number;
@ViewChild('viewport', {read: ViewContainerRef}) _viewport: ViewContainerRef;

@ViewChild('viewport', {read: ViewContainerRef}) _viewport: ViewContainerRef;
@ViewChild('modalPortal', { read: OverlayPortal }) _modalPortal: OverlayPortal;

@ViewChild('overlayPortal', { read: OverlayPortal }) _overlayPortal: OverlayPortal;

@ViewChild('loadingPortal', { read: OverlayPortal }) _loadingPortal: OverlayPortal;

@ViewChild('toastPortal', { read: OverlayPortal }) _toastPortal: OverlayPortal;

constructor(
Expand Down Expand Up @@ -92,9 +89,6 @@ export class IonicApp extends Ion implements OnInit {
this._plt.prepareReady();
}

/**
* @private
*/
_getPortal(portal?: AppPortal): OverlayPortal {
if (portal === AppPortal.LOADING) {
return this._loadingPortal;
Expand All @@ -110,9 +104,6 @@ export class IonicApp extends Ion implements OnInit {
return this._overlayPortal;
}

/**
* @private
*/
_getActivePortal(): OverlayPortal {
const defaultPortal = this._overlayPortal;
const modalPortal = this._modalPortal;
Expand All @@ -139,12 +130,8 @@ export class IonicApp extends Ion implements OnInit {
} else if (hasDefault) {
return defaultPortal;
}

}

/**
* @private
*/
_disableScroll(shouldDisableScroll: boolean) {
if (shouldDisableScroll) {
this.stopScroll().then(() => {
Expand Down
8 changes: 5 additions & 3 deletions src/components/menu/menu-controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Menu } from './menu';
import { MenuType } from './menu-types';
import { Platform } from '../../platform/platform';
import { removeArrayItem } from '../../util/util';
import { removeArrayItem, assert } from '../../util/util';


/**
Expand Down Expand Up @@ -296,14 +296,16 @@ export class MenuController {
/**
* @private
*/
register(menu: Menu) {
_register(menu: Menu) {
assert(this._menus.indexOf(menu) < 0, 'menu was already registered');
this._menus.push(menu);
}

/**
* @private
*/
unregister(menu: Menu) {
_unregister(menu: Menu) {
assert(this._menus.indexOf(menu) >= 0, 'menu is not registered');
removeArrayItem(this._menus, menu);
}

Expand Down
11 changes: 6 additions & 5 deletions src/components/menu/menu-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,21 @@ export class MenuType {
if (!this.isOpening && !shouldComplete) {
isOpen = true;
}

this.ani.onFinish(() => {
const ani = this.ani;
ani.onFinish(() => {
this.isOpening = false;
done(isOpen);
}, true);

let factor = 1 - Math.min(Math.abs(velocity) / 4, 0.7);
let dur = this.ani.getDuration() * factor;
const factor = 1 - Math.min(Math.abs(velocity) / 4, 0.7);
const dur = ani.getDuration() * factor;

this.ani.progressEnd(shouldComplete, currentStepValue, dur);
ani.progressEnd(shouldComplete, currentStepValue, dur);
}

destroy() {
this.ani && this.ani.destroy();
this.ani = null;
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class Menu {
this._cntEle.classList.add('menu-content-' + this.type);

// register this menu with the app's menu controller
this._menuCtrl.register(this);
this._menuCtrl._register(this);
}

/**
Expand Down Expand Up @@ -656,7 +656,7 @@ export class Menu {
* @private
*/
ngOnDestroy() {
this._menuCtrl.unregister(this);
this._menuCtrl._unregister(this);
this._events.destroy();
this._gesture && this._gesture.destroy();
this._type && this._type.destroy();
Expand Down
Loading

0 comments on commit be0b6a8

Please sign in to comment.