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

202
Views
Multiple Progress Bars on Splide.js sliders

I am having 3 Splide.Js sliders on a single page and I would like to add the progress bar as mentioned here -> https://splidejs.com/ under Slider Progress:

This my code so far (which works for the splide itself):

var splides = $('.highlights');

function slider1() {

for ( let i = 0, splideLength = splides.length; i < splideLength; i++ ) {
 
  var splide = new Splide( splides[ i ], {
    // Desktop on down
    gap: '2.4em', // space between slides
    autoWidth: true, // for cards with differing widths
    waitForTransition: true,
    breakpoints: {
      991: {
        // Tablet
      },
      767: {
        // Mobile Landscape
        destroy: true,
      },
      479: {
        // Mobile Portrait
        destroy: 'completely',
      }
    }
  });
  
  var bar = splide.root.querySelector( '.my-slider-progress-bar' );
    
  splide.mount();
  
}
}

slider1();

Where do I put this piece of code to make the bar works with each slide? I am currently getting the error "Cannot read properties of null (reading 'style')"

Progress Bar code:

 // Update the bar width:
  splide.on( 'mounted move', function () {
    var end = splide.Components.Controller.getEnd() + 1;
    bar.style.width = String( 100 * ( splide.index + 1 ) / end ) + '%';
  } );

Thanks for any tips

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

0

between:
var bar = splide.root.querySelector( '.my-slider-progress-bar' );

and:
splide.mount();

such as:
var bar = splide.root.querySelector( '.my-slider-progress-bar' );

  splide.on( 'mounted move', function () {
    var end = splide.Components.Controller.getEnd() + 1;
    bar.style.width = String( 100 * ( splide.index + 1 ) / end ) + '%';
  } );

  splide.mount();
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!