]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/misc/screen.service.ts
Add client helpers to plugins
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / misc / screen.service.ts
index 1cbc96b14b857468746111fb7c96f5717f91ed4f..af75569d9bd66fb61b82cd070d4c30300cfbf1ce 100644 (file)
@@ -18,6 +18,10 @@ export class ScreenService {
     return this.getWindowInnerWidth() < 500
   }
 
+  isInTouchScreen () {
+    return 'ontouchstart' in window || navigator.msMaxTouchPoints
+  }
+
   // Cache window inner width, because it's an expensive call
   private getWindowInnerWidth () {
     if (this.cacheWindowInnerWidthExpired()) this.refreshWindowInnerWidth()
@@ -32,6 +36,8 @@ export class ScreenService {
   }
 
   private cacheWindowInnerWidthExpired () {
+    if (!this.lastFunctionCallTime) return true
+
     return new Date().getTime() > (this.lastFunctionCallTime + this.cacheForMs)
   }
 }