NickPiscitelli / Glider.js

A fast, lightweight, dependency free, native scrolling carousel alternative!
https://nickpiscitelli.github.io/Glider.js
MIT License
3.26k stars 296 forks source link

Set initital slide index #215

Open multipliedtwice opened 2 years ago

multipliedtwice commented 2 years ago

hello, thank you for the great library. Is there any way to set the initial slide by index without using the method scrollItem and watching animation?

Also is there any way to enable drag snap?

NickPiscitelli commented 2 years ago

You can use scrollTo and pass 0 for the second argument. You will need to pass the offset directly though which you can get by item width times the index.