mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Fix: log scroll ux
This commit is contained in:
parent
df00d1c53d
commit
44dd8c6926
@ -14,12 +14,14 @@ export default function Logs () {
|
||||
const { translation } = useI18n()
|
||||
const { t } = translation('Logs')
|
||||
const logsStreamReader = useLogsStreamReader()
|
||||
const scrollHeightRef = useRef(listRef.current?.scrollHeight ?? 0)
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const ul = listRef.current
|
||||
if (ul != null) {
|
||||
ul.scrollTop = ul.scrollHeight
|
||||
if (ul != null && scrollHeightRef.current === (ul.scrollTop + ul.clientHeight)) {
|
||||
ul.scrollTop = ul.scrollHeight - ul.clientHeight
|
||||
}
|
||||
scrollHeightRef.current = ul?.scrollHeight ?? 0
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user