src/client/app/components/home/home.component.ts
moduleId | module.id |
selector | sd-home |
styleUrls | home.component.css |
templateUrl | home.component.html |
Properties |
Methods |
constructor(_appService: AppService, routerExt: RouterExtensions)
|
Private _calcHeight |
_calcHeight()
|
Returns :
void
|
ngAfterViewInit |
ngAfterViewInit()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
onWindowResize |
onWindowResize(event: any)
|
Returns :
void
|
el |
el:
|
Type : ElementRef
|
Decorators : ViewChild
|
height |
height:
|
Type : number
|
Public routerExt |
routerExt:
|
Type : RouterExtensions
|
timeOut |
timeOut:
|
Type : any
|
import {Component, ElementRef, ViewChild, OnInit, AfterViewInit} from '@angular/core';
import {AppService, RouterExtensions} from '../../modules/core/services/index';
@Component({
moduleId: module.id,
selector: 'sd-home',
templateUrl: 'home.component.html',
styleUrls: ['home.component.css']
})
export class HomeComponent implements OnInit, AfterViewInit {
@ViewChild('el') el: ElementRef;
height: number;
timeOut: any;
constructor(private _appService: AppService,
public routerExt: RouterExtensions) {
}
ngOnInit() {
if (typeof document === 'object' && document.title) {
document.title = 'home';
this._calcHeight();
}
}
ngAfterViewInit(): void {
this._appService.isPreloader = false;
}
onWindowResize(event: any) {
if (this.timeOut) {
window.clearTimeout(this.timeOut);
}
this.timeOut = window.setTimeout(() => {
this._calcHeight();
}, 64);
}
private _calcHeight() {
if (typeof document === 'object' && document.title) {
this.height = this.el.nativeElement.offsetParent.offsetHeight - (48 * 2);
}
}
}
<div class="container-fluid" #el [ngStyle]="{'height': height + 'px'}" (resize)="onWindowResize($event)">
<ul class="nav nav-pills nav-stacked">
<li>
<a [routerLink]="['/puzzle']" class="btn btn-default btn-lg btn-block">{{'PLAY' | translate}}</a>
</li>
<li>
<a [routerLink]="['/about']" class="btn btn-default btn-lg btn-block">{{'ABOUT' | translate}}</a>
</li>
<li>
<a href="#" class="btn btn-default btn-lg btn-block">{{'GOOGLE_PLAY' | translate}}</a>
</li>
<li>
<a href="#" class="btn btn-default btn-lg btn-block">{{'APP_STORE' | translate}}</a>
</li>
</ul>
</div>