1//listen for window resize event
2window.addEventListener('resize', function(event){
3 var newWidth = window.innerWidth;
4 var newHeight = window.innerHeight;
5});
1// Cross-browser solution (IE support)
2var resizeEvent = window.document.createEvent('UIEvents');
3resizeEvent.initUIEvent('resize', true, false, window, 0);
4window.dispatchEvent(resizeEvent);
1function resizedw(){
2 // Haven't resized in 100ms!
3}
4
5var doit;
6window.onresize = function(){
7 clearTimeout(doit);
8 doit = setTimeout(resizedw, 100);
9};
10
1resizeObservable$: Observable<Event>
2resizeSubscription$: Subscription
3
4ngOnInit() {
5 this.resizeObservable$ = fromEvent(window, 'resize')
6 this.resizeSubscription$ = this.resizeObservable$.subscribe( evt => {
7 console.log('event: ', evt)
8 })
9}