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

88
Views
Try to do a progress bar in javascript

I'm starting to code this year and sorry if my english is not good enough, I have a problem with a progress bar with JS, I have on my console an "uncaught TypeError who charge infinitly and say to me that we can charge the properties on style... The first step was working but when the bar is supposed to become interactive it's not working

const tll = gasp.timeline({
  paused: true
});

tll.to("#percent", "#bar", {
  duration: .2,
  opacity: 0,
  zIndex: -1
});

tll.to("#preloader", {
  duration: .8,
  width: "0%"
});

tll.from(".container", {
  duration: 1.5,
  y: "-150%"
}, "-=.2");

tll.to("container h1", {
  opacity: 1,
  textShadow: "12px 20px rgba(255, 255, 255,0.23)",
  skewY: 10,
  y: "10%",
  stagger: {
    amount: .4
  }
});

var width = 1;
var bar = document.getElementById("barconfirm");
var id;

function move() {
  id = setInterval(frame, 10);
}

function frame() {
  if (width > 100) {
    clearInterval(id);
    tll.play();
  } else {
    width++;
    bar.style.width = width + "%";
    document.getElementById("percent").innerHTML = width + "%";
  }
}
* {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#preloader {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  z-index: 100;
  background-color: #0f0f0f;
  flex-direction: column;
}

#percent {
  color: white;
  font-family: "Neutral Face";
}

#bar {
  width: 60%;
  margin-top: 20%;
}

#barconfirm {
  width: 1%;
  padding: 1px 0px;
  background-color: white;
}

.container {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  background-color: gray;
}

.container h1 {
  font-family: 'Monument';
  text-transform: uppercase;
  font-size: 40px;
  opacity: 0;
}
<body onload="move()">

  <div id="preloader">
    <div id="percent">1%</div>
    
    <div id="bar">
      <div id="barconfirm"></div>
    </div>
  </div>
  
  <div class="container">
    <h1>Leo Clemente</h1>
  </div>

Thanks to you all for your help, I want if you can an explanation more than just a code because I'm here to learn too and have a great day!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue in passing the selector to the tll.to method, it accepts ONE selector, so choose one of yours for tll.to("#percent", "#bar", {...}).

It will work as well whether you choose percent or bar. Also, according to the document, the dependency variable name is gsap.

You can check out an online snippet from here

about 4 years ago · Juan Pablo Isaza Report
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!