Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bug) fix bug #95

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading