mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
rewrote window resize event using redux
This commit is contained in:
@@ -3,10 +3,13 @@ import {
|
||||
ChangeDetectionStrategy,
|
||||
ViewEncapsulation,
|
||||
OnDestroy,
|
||||
OnInit
|
||||
OnInit, HostListener
|
||||
} from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { TranslateService } from "ng2-translate";
|
||||
import { HostWindowState } from "./shared/host-window.reducer";
|
||||
import { Store } from "@ngrx/store";
|
||||
import { HostWindowActions } from "./shared/host-window.actions";
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
@@ -27,7 +30,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
|
||||
constructor(
|
||||
private translate: TranslateService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private store: Store<HostWindowState>
|
||||
) {
|
||||
// this language will be used as a fallback when a translation isn't found in the current language
|
||||
translate.setDefaultLang('en');
|
||||
@@ -47,4 +51,11 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
private onResize(event): void {
|
||||
this.store.dispatch(
|
||||
HostWindowActions.resize(event.target.innerWidth, event.target.innerHeight)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user