ganlanyuan / tiny-slider

Vanilla javascript slider for all purposes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Center horizontally the active slide

Loic57 opened this issue · comments

Hi there,

I have a tiny slider in my app. Around 7 slides and I would like to center horizontally the slide which has the active class (see screenshot below). Do you have any idea how I can achieve that ?

image

I'm working on local so no demo link but here is my slider config :
var slider = tns({ container: '.calendar-slider', items: 4, slideBy: 1, autoplay: false, nav: false, controls: false, mouseDrag: true, gutter: 15, loop: false, autoWidth: true });

Tiny slider version 2.9.3
Chrome Version 92.0.4515.159
windows 10 pro

Without knowing the HTML it is hard to exactly pinpoint, I would try this:
startIndex: jQuery('.activeClassOfElement').parent()index(),
center: true

Where the jQuery('.activeClassOfElement').parent()index() would be the active classname of you element.