Compare commits

..

No commits in common. "32b05d76f094c4ea0f5a499692e5c244a5628d43" and "be10f376f4333f4fb92ba3d3fe09748b297c693f" have entirely different histories.

View File

@ -10,12 +10,10 @@ import { Logo } from "./Logo"
import { useThemeDetector } from "../utils/useThemeDetector" import { useThemeDetector } from "../utils/useThemeDetector"
import { TextItem } from "./TextItem" import { TextItem } from "./TextItem"
import texts from "../signals/texts" import texts from "../signals/texts"
import { useDebounce } from "../utils/useDebounce"
export default function InfiniteCanvas() { export default function InfiniteCanvas() {
const containerRef = useRef<HTMLDivElement>(null) const containerRef = useRef<HTMLDivElement>(null)
const isDarkTheme = useThemeDetector() const isDarkTheme = useThemeDetector()
const { debounce } = useDebounce()
useEffect(() => { useEffect(() => {
const initPos = getInitialPosition(canvasDimentsion) const initPos = getInitialPosition(canvasDimentsion)
@ -29,24 +27,22 @@ export default function InfiniteCanvas() {
} }
function _updatePosition() { function _updatePosition() {
debounce(() => { localStorage.setItem("pos", JSON.stringify({
localStorage.setItem("pos", JSON.stringify({ left: window.scrollX,
left: window.scrollX, top: window.scrollY
top: window.scrollY }))
}))
})
} }
_updateDimensions() _updateDimensions()
window.addEventListener("resize", _updateDimensions) window.addEventListener("resize", _updateDimensions)
window.addEventListener("scroll", _updatePosition) window.addEventListener("scrollend", _updatePosition)
notes.loadLocalStorage() notes.loadLocalStorage()
images.loadLocalStorage() images.loadLocalStorage()
texts.loadLocalStorage() texts.loadLocalStorage()
return () => { return () => {
window.removeEventListener("resize", _updateDimensions) window.removeEventListener("resize", _updateDimensions)
window.removeEventListener("scroll", _updatePosition) window.removeEventListener("scrollend", _updatePosition)
} }
}, []) }, [])