Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
How can I make my progressBar go wider as settimeout function passes?

So I have a settimeout() function which changes background images of page every two seconds, and I need to have a progress bar at the bottom of the page, which gets from 0% to 100% width and back everytime as image changing function happens.

Image changing function:

function changeImage(){
    
        setTimeout((function(images)
    {
        let index = -1, changeImage;
        changeImage = function()
        {
            index = (index + 1) % images.length;
            hero.style.backgroundImage = 'url(' + images[index] + ')';
        };
        progressBar();
        changeImage();
        return changeImage;
    }([
        'file:///D:/Dev/gym/img/hero.jpg',
        'file:///D:/Dev/gym/img/hero_2.jpg',
    ])), 2000);
    }

Function for progress bar(which I haven't figured out yet):

function progressBar(){

        setTimeout(() => {
            progress.style.width = 100 + '%';
        }, 2000);
    }

What my page looks like: enter image description here

So there's a bar at the bottom, and it should widen slowly as changeImage function goes off, but I have trouble understanding how I can do it.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda