Add auto homing when window resize
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import FitFullScreen from '@/components/common/FitFullScreen'
|
import FitFullScreen from '@/components/common/FitFullScreen'
|
||||||
import FitCenter from '@/components/common/FitCenter'
|
import FitCenter from '@/components/common/FitCenter'
|
||||||
import { MainFrameworkContext } from '@/pages/MainFramework'
|
import { MainFrameworkContext } from '@/pages/MainFramework'
|
||||||
@@ -24,6 +24,14 @@ const Home: React.FC = () => {
|
|||||||
})
|
})
|
||||||
}, [setNavbarHidden, setPreventScroll])
|
}, [setNavbarHidden, setPreventScroll])
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const handleWindowResize = () => {
|
||||||
|
handleScrollToContent(currentContent)()
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', handleWindowResize)
|
||||||
|
return () => window.removeEventListener('resize', handleWindowResize)
|
||||||
|
})
|
||||||
|
|
||||||
const handleScrollToContent = (index: number) => {
|
const handleScrollToContent = (index: number) => {
|
||||||
return () => {
|
return () => {
|
||||||
if (!index) {
|
if (!index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user