Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda