improve orderbook vertical centering

This commit is contained in:
tjs 2022-09-20 21:18:04 -04:00
parent b5adfae658
commit 98bc6b8fce
1 changed files with 10 additions and 1 deletions

View File

@ -147,7 +147,9 @@ const groupBy = (
})
return sortedGroups
}
const depth = 60
const Orderbook = () => {
const { t } = useTranslation('common')
const selectedMarket = mangoStore((s) => s.selectedMarket.current)
@ -197,7 +199,14 @@ const Orderbook = () => {
const verticallyCenterOrderbook = useCallback(() => {
const element = orderbookElRef.current
if (element) {
element.scrollTop = (element.scrollHeight - element.offsetHeight) / 2
if (element.scrollHeight > window.innerHeight) {
element.scrollTop =
(element.scrollHeight - element.scrollHeight) / 2 +
(element.scrollHeight - window.innerHeight) / 2 +
94
} else {
element.scrollTop = (element.scrollHeight - element.offsetHeight) / 2
}
}
}, [])