Skip to content

Commit

Permalink
To correct github star numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
sk0618054 committed Mar 10, 2024
1 parent 5577014 commit 7335d10
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions components/utils/countingNumbers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ export default function CountingNumbers({
interval?: number;
duration?: number;
}) {

const [top, setTop] = useState<boolean>(true);
const [starsCount, setStarsCount] = useState<number>(3000);
const [number, setNumber] = useState(start);


// detect whether user has scrolled the page down by 10px
const scrollHandler = () => {
window.pageYOffset > 10 ? setTop(false) : setTop(true);
Expand Down Expand Up @@ -57,8 +55,9 @@ export default function CountingNumbers({
fetchStarsCount();
}, [starsCount]); // Include starsCount as a dependency


let increment = Math.floor(Math.abs(start - starsCount) / (duration / interval));
let increment = Math.floor(
Math.abs(start - starsCount) / (duration / interval)
);
if (increment === 0) {
increment = 1;
}
Expand Down Expand Up @@ -99,11 +98,9 @@ export default function CountingNumbers({
}
}, [isInView]);



return (
<p className={className} ref={ref}>
{Intl.NumberFormat().format(number)}
{Intl.NumberFormat().format(starsCount)}
</p>
);
}
}

0 comments on commit 7335d10

Please sign in to comment.