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

284
Views
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
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!