From 157fbade81565721c18f33a0342c918902c0596e Mon Sep 17 00:00:00 2001 From: thislight Date: Sat, 21 Dec 2024 17:28:53 +0800 Subject: [PATCH] Home: fix minor type error --- src/timelines/Home.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/timelines/Home.tsx b/src/timelines/Home.tsx index a016e45..99e4fd1 100644 --- a/src/timelines/Home.tsx +++ b/src/timelines/Home.tsx @@ -4,6 +4,7 @@ import { onMount, type ParentComponent, createRenderEffect, + createEffect, } from "solid-js"; import { useDocumentTitle } from "../utils"; import Scaffold from "~material/Scaffold"; @@ -58,6 +59,7 @@ const Home: ParentComponent = (props) => { const recalculateTabIndicator = () => { scrollEventLockReleased = false; try { + if (!panelList!) return; const { x: panelX, width: panelWidth } = panelList.getBoundingClientRect(); let minIdx = +Infinity, @@ -95,11 +97,9 @@ const Home: ParentComponent = (props) => { } }; - createRenderEffect(() => { + createEffect(() => { makeEventListener(window, "resize", requestRecalculateTabIndicator); - }); - onMount(() => { requestAnimationFrame(recalculateTabIndicator); }); @@ -110,7 +110,7 @@ const Home: ParentComponent = (props) => { }; const onTabClick = (idx: number) => { - const items = panelList.querySelectorAll(".tab-panel"); + const items = panelList!.querySelectorAll(".tab-panel"); if (items.length > idx) { items.item(idx).scrollIntoView({ block: "start", behavior: "smooth" }); }