Skip to content

Commit

Permalink
fix: add touch input text element
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet-jordan committed Apr 3, 2024
1 parent 09429d0 commit 585cb0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 0 additions & 9 deletions src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
</style>
</head>
<body>
<canvas id="canvas" width="789" height="532"></canvas>
<input type="text" id="touchInput" />
</body>
</html>
5 changes: 3 additions & 2 deletions src/js/jagex2/client/GameShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 585cb0a

Please sign in to comment.