Skip to content
Snippets Groups Projects
Commit 3534c232 authored by jojohoch's avatar jojohoch
Browse files

Determine the OS to decide whether it is a mobile device

parent 2e5fab7f
No related branches found
Tags editor/2.3.0+player/2.3.0
No related merge requests found
Pipeline #52521 passed
......@@ -6,12 +6,14 @@ import { Injectable } from '@angular/core';
export class DeviceService {
hasHardwareKeyboard: boolean = false;
private readonly isTouch!: boolean;
private readonly isMobile!: boolean;
constructor() {
this.isTouch = ('ontouchstart' in window) || (navigator && navigator.maxTouchPoints > 0);
this.isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}
get isMobileWithoutHardwareKeyboard(): boolean {
return this.isTouch && !this.hasHardwareKeyboard;
return this.isMobile && this.isTouch && !this.hasHardwareKeyboard;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment