Add auto homing when window resize

This commit is contained in:
2023-09-13 23:32:02 +08:00
parent c6b6c76152
commit 100c8afbee

View File

@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect } from 'react'
import FitFullScreen from '@/components/common/FitFullScreen'
import FitCenter from '@/components/common/FitCenter'
import { MainFrameworkContext } from '@/pages/MainFramework'
@@ -24,6 +24,14 @@ const Home: React.FC = () => {
})
}, [setNavbarHidden, setPreventScroll])
useLayoutEffect(() => {
const handleWindowResize = () => {
handleScrollToContent(currentContent)()
}
window.addEventListener('resize', handleWindowResize)
return () => window.removeEventListener('resize', handleWindowResize)
})
const handleScrollToContent = (index: number) => {
return () => {
if (!index) {