From 585cb0a93bb5c27b7e3e965fd381140ba1107469 Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 3 Apr 2024 15:20:56 -0400 Subject: [PATCH] fix: add touch input text element --- src/html/index.html | 9 --------- src/js/jagex2/client/GameShell.ts | 5 +++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/html/index.html b/src/html/index.html index 619821cc..fa6427dc 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -31,18 +31,9 @@ -webkit-tap-highlight-color: rgba(255, 255, 255, 0); z-index: -1; } - - #touchInput { - position: absolute; - top: 0; - left: 0; - opacity: 0; /* Make the input element transparent */ - pointer-events: none; /* Disable pointer events on the input element */ - } - \ No newline at end of file diff --git a/src/js/jagex2/client/GameShell.ts b/src/js/jagex2/client/GameShell.ts index 5d31ad20..13a6df4f 100644 --- a/src/js/jagex2/client/GameShell.ts +++ b/src/js/jagex2/client/GameShell.ts @@ -591,7 +591,7 @@ export default abstract class GameShell { this.touchInput = null; } - // const document = document; // Replace with your document reference + const document: Document = window.document; this.touchInput = document.createElement('touchInput'); if (this.insideUsernameArea()) { this.touchInput.setAttribute('id', 'username'); @@ -673,7 +673,8 @@ export default abstract class GameShell { }; get isMobile(): boolean { - return navigator.maxTouchPoints > 0 /* || navigator.msMaxTouchPoints > 0*/; + const touch: string[] = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone']; + return touch.some((keyword: string): boolean => navigator.userAgent.includes(keyword)); } private insideViewportArea(): boolean {