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,
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" });
}