35 lines
870 B
TypeScript
35 lines
870 B
TypeScript
import { WindowRefService } from './../../services/window-ref.service';
|
|
import { Component, HostListener, OnInit } from '@angular/core';
|
|
|
|
|
|
|
|
@Component({
|
|
selector: 'services-component',
|
|
templateUrl: './services.component.html',
|
|
styleUrls: ['./services.component.css'],
|
|
})
|
|
export class ServicesComponent implements OnInit {
|
|
|
|
public columnCount: number = 2;
|
|
private smallColumnCount: number = 1;
|
|
private medColumnCount: number = 2;
|
|
private smallWidth: number = 500;
|
|
|
|
constructor(private windowRef: WindowRefService){ }
|
|
|
|
ngOnInit(){
|
|
let event = { target:this.windowRef.getWindow() };
|
|
this.onResize(event);
|
|
}
|
|
|
|
@HostListener('window:resize', ['$event'])
|
|
onResize(event) {
|
|
if (event.target.innerWidth < this.smallWidth){
|
|
this.columnCount = this.smallColumnCount;
|
|
} else {
|
|
this.columnCount = this.medColumnCount;
|
|
}
|
|
}
|
|
|
|
}
|