mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
Revert "opt: auto-scroll behavior to reactivate only on user scroll"
This reverts commit 848f6277cb56a0829e7f1da61f2f3ab21ae1064c.
This commit is contained in:
parent
0b2f64f42d
commit
98be9d3065
@ -44,7 +44,6 @@ const Logs: React.FC = () => {
|
||||
return localStorage.getItem(LOGS_FILTER_KEY) || ''
|
||||
})
|
||||
const [trace, setTrace] = useState(true)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const virtuosoRef = useRef<VirtuosoHandle>(null)
|
||||
const filteredLogs = useMemo(() => {
|
||||
@ -58,22 +57,6 @@ const Logs: React.FC = () => {
|
||||
localStorage.setItem(LOGS_FILTER_KEY, filter)
|
||||
}, [filter])
|
||||
|
||||
useEffect((): void | (() => void) => {
|
||||
if (!trace) {
|
||||
const container = containerRef.current
|
||||
if (container) {
|
||||
const handleScroll = () => {
|
||||
setTrace(true)
|
||||
container.removeEventListener('wheel', handleScroll)
|
||||
}
|
||||
container.addEventListener('wheel', handleScroll)
|
||||
return () => {
|
||||
container.removeEventListener('wheel', handleScroll)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [trace])
|
||||
|
||||
useEffect(() => {
|
||||
if (!trace) return
|
||||
virtuosoRef.current?.scrollToIndex({
|
||||
@ -113,9 +96,7 @@ const Logs: React.FC = () => {
|
||||
variant={trace ? 'solid' : 'bordered'}
|
||||
title={t('logs.autoScroll')}
|
||||
onPress={() => {
|
||||
if (trace) {
|
||||
setTrace(false)
|
||||
}
|
||||
setTrace((prev) => !prev)
|
||||
}}
|
||||
>
|
||||
<IoLocationSharp className="text-lg" />
|
||||
@ -136,7 +117,7 @@ const Logs: React.FC = () => {
|
||||
</div>
|
||||
<Divider />
|
||||
</div>
|
||||
<div className="h-[calc(100vh-100px)] mt-px" ref={containerRef}>
|
||||
<div className="h-[calc(100vh-100px)] mt-px">
|
||||
<Virtuoso
|
||||
ref={virtuosoRef}
|
||||
data={filteredLogs}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user