Skip to content

Commit

Permalink
Merge pull request #95 from MichiganDataScienceTeam/feat/dynamic_fact
Browse files Browse the repository at this point in the history
(bug) fix bug
  • Loading branch information
Weile-Zheng authored Sep 15, 2024
2 parents d71831f + 2845fb9 commit 9ca6cfe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ function ProjectCard({ json, basePath }) {
);
}

import React, { useEffect } from "react";

function Factbox({ fact, closer }) {
if (typeof window !== "undefined") {
useEffect(() => {
const elements = document.querySelectorAll(".number");

const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
Expand All @@ -190,10 +193,12 @@ function Factbox({ fact, closer }) {
}
});
});

elements.forEach((element) => {
observer.observe(element);
});
}
}, []); // Empty dependency array means this effect runs once after the initial render

return (
<div className="text-left bg-grey p-4 rounded-lg w-full">
<h2 className="text-4xl font-semibold my-2">
Expand Down

0 comments on commit 9ca6cfe

Please sign in to comment.