Skip to content

Commit

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

import React, { useEffect } from "react";

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

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

elements.forEach((element) => {
observer.observe(element);
});

return () => {
elements.forEach((element) => {
observer.unobserve(element);
});
};
}, []);

}
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 d71831f

Please sign in to comment.