Home: fix minor type error
This commit is contained in:
parent
14beef39c2
commit
157fbade81
1 changed files with 4 additions and 4 deletions
|
@ -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" });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue