Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

set isMobile value to an observable

bsatarnejad758e0f889d13
diff --git a/frontend/src/app/core/browser/device.service.ts b/frontend/src/app/core/browser/device.service.ts
index f89c9167aa4..8d64aff4227 100644
--- a/frontend/src/app/core/browser/device.service.ts
+++ b/frontend/src/app/core/browser/device.service.ts
@@ -1,10 +1,17 @@
import { Injectable } from '@angular/core';
+import { BehaviorSubject } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class DeviceService {
- public mobileWidthTreshold = 680;
-
public get isMobile():boolean {
- return (window.innerWidth < this.mobileWidthTreshold);
+ return window.matchMedia('(max-width: 679px)').matches;
+ }
+
+ constructor() {
+ window.addEventListener('resize', () => {
+ this.isMobile$.next(this.isMobile);
+ });
}
+
+ public isMobile$ = new BehaviorSubject<boolean>(this.isMobile);
}