Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

314
Views
React - animation for scrolling percentage

I am referencing the animation of circle-ci homepage

enter image description here

I've tried a library called react-scroll-percentage which would update the value of variable percentage if I scroll it down.

Now, I have a few problems.

This is my current UI:
enter image description here

  1. When I keep scrolling and arrive to my div with className container, it will NOT stop scrolling as circle-ci homepage did.
  2. The update of percentage is not big enough. Even I scroll to the bottom of the page, the percentage will only be 0.5% at most, which is far from 100%

Can anyone give me suggestion of how I should do it?

App.jsx

import "./styles.css";
import { useScrollPercentage } from "react-scroll-percentage";

export default function App() {
  const [ref, percentage] = useScrollPercentage({
    threshold: 0
  });

  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
      <h2>{`Percentage scrolled: ${percentage.toPrecision(2)}%.`}</h2>
      <div className="container" ref={ref}>
        <div className="check-line">
          <div className="check-progress" style={{ width: percentage }} />
        </div>
      </div>
      <div
        style={{
          marginTop: "50px",
          height: "400px",
          width: "100%",
          border: "1px solid red"
        }}
      ></div>
    </div>
  );
}

style.css

.App {
  font-family: sans-serif;
  text-align: center;
}

.container {
  position: relative;
  border: 1px solid grey;
  height: 90px;
  width: 100%;
}

.check-line {
  position: absolute;
  top: 26px;
  z-index: -1;
  left: 12.5%;
  right: 12.5%;
  height: 1px;
  background-color: #f3f3f3;
}

.check-progress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: green;
}

Codesandbox:
https://codesandbox.io/s/serverless-rain-5l8w5?file=/src/styles.css:0-405

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!