Skip to content

Commit

Permalink
Fix iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed May 24, 2024
1 parent a612892 commit f24657b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion arthur.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>Arthur</h1>
<p data-keycode="116">Room</p>
<p data-keycode="117"><span class="arthurfull">Text only</span><span class="arthurshort">Text</span></p>
</div>
<canvas id="canvas" height="400"></canvas>
<canvas id="canvas"></canvas>
<textarea id="textinput" autocapitalize="off" rows="1"></textarea>
</div>
</div>
Expand Down
16 changes: 9 additions & 7 deletions interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ const textinput_elem = document.getElementById('textinput')
// Prevent iOS from zooming in when focusing input, but allow Android to still pinch zoom
// As they handle the maximum-scale viewport meta option differently, we will conditionally add it only in iOS
// Idea from https://stackoverflow.com/a/62750441/2854284
if (/iPhone OS/i.test(navigator.userAgent)) {
document.head.querySelector('meta[name="viewport"]').content = 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1'
}
/* document.addEventListener('DOMContentLoaded', (event) => {
if (/iPhone OS/i.test(navigator.userAgent)) {
document.head.querySelector('meta[name="viewport"]').content = 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1'
}
}) */

visualViewport.addEventListener('resize', () => {
/* visualViewport.addEventListener('resize', () => {
const height = visualViewport.height
document.documentElement.style.height = `${height}px`
// Safari might have scrolled weirdly, so try to put it right
window.scrollTo(0, 0)
setTimeout(() => window.scrollTo(0, 0), 500)
})
}) */

// Mobile input event handlers
canvas_elem.addEventListener('touchstart', ev => {
Expand Down Expand Up @@ -74,7 +76,7 @@ textinput_elem.addEventListener('keyup', ev => {
})

// Arthur buttons
const arthurmodes = document.getElementById('arthurmodes')
/*const arthurmodes = document.getElementById('arthurmodes')
if (arthurmodes) {
arthurmodes.addEventListener('click', ev => {
let target = ev.target
Expand All @@ -86,7 +88,7 @@ if (arthurmodes) {
}
textinput_elem.focus()
})
}
}*/

// Send a fake keydown/keyup
const named_codes = {
Expand Down

0 comments on commit f24657b

Please sign in to comment.