bqworks / accordion-slider-js

Modular accordion slider written in Vanilla JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Current index

hog-seruj opened this issue · comments

Is it possible to get the current index after the move the page?

I don't use autoplay and I need to open nextPanel() after scroll page.

Looks like I found a way to resolve my task.
accordionSlider.addEventListener('pageScroll', (event) => { const currentPage = accordionSlider.getCurrentPage(); const openIndex = currentPage * accordionSlider.getVisiblePanels(); accordionSlider.openPanel(openIndex + 1); });

Glad you've worked it out and thanks for sharing the solution! By the way, you can also get the current page from the event object: event.detail.index.