Skip to content

Commit

Permalink
Merge pull request #235 from mermaid-js/fix/non-finite
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCoder authored Dec 27, 2024
2 parents 120b6f6 + 5942912 commit 5004c6b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/functions/useIntersectionTop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export default function useIntersectionTop() {
const detectorHeight = Math.ceil(
document.documentElement.scrollHeight / DETECTOR_COUNT,
);
const threshold = [...Array(detectorHeight + 1).keys()].map(
(i) => i / detectorHeight,
);
const threshold = [...Array(detectorHeight + 1).keys()]
.map((i) => i / detectorHeight)
.filter((i) => i >= 0 && i <= 1);
detectors.forEach((detector, index) => {
(detector as HTMLElement).style.top = index * detectorHeight + "px";
(detector as HTMLElement).style.height = detectorHeight + "px";
Expand All @@ -84,7 +84,7 @@ export default function useIntersectionTop() {
});
});
onUnmounted(() => {
observer.disconnect();
observer?.disconnect();
});
return top;
}

0 comments on commit 5004c6b

Please sign in to comment.