Randomize the start slide of a slider

1 reply · opened Sep 4, 2019

KkevinleighSep 4, 2019

Sorry to ask so many questions but this would really help
Is it possible to randomize the start point of a slider

SSemicolon WebSTAFFSep 5, 2019

Hello,

While this is currently not available out of the Box, this can surely be implemented with minor Customizations. Please find the following code in the js/functions.js File inside the sliderRun: function() Function Block:

var elementNavNext = element.find('.slider-arrow-right'),
	elementNavPrev = element.find('.slider-arrow-left'),
	elementScrollBar = element.find('.swiper-scrollbar');

and add the following code just below the above lines:

var elementInitSlide = Math.floor( Math.random() * element.find('.swiper-slide:not(.swiper-slide-duplicate)').length );

Then find the following JS Setting in the same Function Block:

slidesPerView: 1,

and replace it with:

slidesPerView: 1,
initialSlide: elementInitSlide,

This should definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard