fix ios scrolling in bet panel

This commit is contained in:
mantikoros 2022-06-10 11:35:53 -05:00
parent 86581a421a
commit e28dfaaa80
2 changed files with 19 additions and 1 deletions

View File

@ -37,6 +37,7 @@ import {
import { SellRow } from './sell-row'
import { useSaveShares } from './use-save-shares'
import { SignUpPrompt } from './sign-up-prompt'
import { isIOS } from 'web/lib/util/device'
export function BetPanel(props: {
contract: BinaryContract
@ -203,7 +204,10 @@ function BuyPanel(props: {
const [inputRef, focusAmountInput] = useFocus()
useEffect(() => {
if (selected) focusAmountInput()
if (selected) {
if (isIOS()) window.scrollTo(0, window.scrollY + 200)
focusAmountInput()
}
}, [selected, focusAmountInput])
function onBetChoice(choice: 'YES' | 'NO') {

14
web/lib/util/device.ts Normal file
View File

@ -0,0 +1,14 @@
export function isIOS() {
return (
[
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod',
].includes(navigator.platform) ||
// iPad on iOS 13 detection
(navigator.userAgent.includes('Mac') && 'ontouchend' in document)
)
}