@snap-carousel/core
v0.0.19-next.4
Published
### Installation
Downloads
1,054
Readme
SimplebarReact
Installation
- Via npm
npm install @snap-carousel/core --save
- Via Yarn
yarn add @snap-carousel/core
Usage
Check out the Demo project or our live Codesandbox example.
If you are using a module loader (like Webpack) you first need to load SimpleBar:
import { getActiveSnap, scrollTo, dragToScroll } from '@snap-carousel/core';
import '@snap-carousel/core/dist/styles.css';
const root = document.querySelector('.carousel');
const activeSnap = getActiveSnap({
root,
onChange: (snapIndex) => {
console.log('active snap changed to: ', snapIndex);
},
});
const activeSnapIndex = activeSnap.getActiveIndex();
scrollTo({ root, index: 2, duration: 0 });
Don't forget to import both css and js in your project!