Home: fix minor type error

This commit is contained in:
thislight 2024-12-21 17:28:53 +08:00
parent 14beef39c2
commit 157fbade81
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E

View file

@ -4,6 +4,7 @@ import {
onMount, onMount,
type ParentComponent, type ParentComponent,
createRenderEffect, createRenderEffect,
createEffect,
} from "solid-js"; } from "solid-js";
import { useDocumentTitle } from "../utils"; import { useDocumentTitle } from "../utils";
import Scaffold from "~material/Scaffold"; import Scaffold from "~material/Scaffold";
@ -58,6 +59,7 @@ const Home: ParentComponent = (props) => {
const recalculateTabIndicator = () => { const recalculateTabIndicator = () => {
scrollEventLockReleased = false; scrollEventLockReleased = false;
try { try {
if (!panelList!) return;
const { x: panelX, width: panelWidth } = const { x: panelX, width: panelWidth } =
panelList.getBoundingClientRect(); panelList.getBoundingClientRect();
let minIdx = +Infinity, let minIdx = +Infinity,
@ -95,11 +97,9 @@ const Home: ParentComponent = (props) => {
} }
}; };
createRenderEffect(() => { createEffect(() => {
makeEventListener(window, "resize", requestRecalculateTabIndicator); makeEventListener(window, "resize", requestRecalculateTabIndicator);
});
onMount(() => {
requestAnimationFrame(recalculateTabIndicator); requestAnimationFrame(recalculateTabIndicator);
}); });
@ -110,7 +110,7 @@ const Home: ParentComponent = (props) => {
}; };
const onTabClick = (idx: number) => { const onTabClick = (idx: number) => {
const items = panelList.querySelectorAll(".tab-panel"); const items = panelList!.querySelectorAll(".tab-panel");
if (items.length > idx) { if (items.length > idx) {
items.item(idx).scrollIntoView({ block: "start", behavior: "smooth" }); items.item(idx).scrollIntoView({ block: "start", behavior: "smooth" });
} }