Skip to content

Instantly share code, notes, and snippets.

@MT--
Last active January 9, 2018 07:54
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MT--/505a1c385f08fa1b0d6f6f3648ddf582 to your computer and use it in GitHub Desktop.
Save MT--/505a1c385f08fa1b0d6f6f3648ddf582 to your computer and use it in GitHub Desktop.
import { Directive } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Directive({
selector: '[hideTabs]'
})
export class HideTabsDirective {
constructor(private viewCtrl: ViewController) {
// hide tabs when view loads
this.viewCtrl.didEnter.subscribe(() => {
let tabs = document.querySelectorAll('.tabbar');
if ( tabs !== null ) {
Object.keys(tabs).map((key) => {
tabs[ key ].style.transform = 'translateY(56px)';
});
} // end if
});
// show tabs when view exits
this.viewCtrl.willLeave.subscribe(() => {
let tabs = document.querySelectorAll('.tabbar');
if ( tabs !== null ) {
Object.keys(tabs).map((key) => {
tabs[ key ].style.transform = 'translateY(0)';
});
} // end if
});
}
}
@0xHexE
Copy link

0xHexE commented Dec 24, 2017

Hey we can use for of instead

if ( tabs !== null ) {
        Object.keys(tabs).map((key) => {
          tabs[ key ].style.transform = 'translateY(0)';
        });
}

eg.

      for (let tab of tabs) {
        tab.style.transform = 'translateY(0)';
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment