Bi-cycle
Bi-cycle assists in making infinite carousels and sliders by handling the index logic for you.

npm: npm i bi-cycle
Source: SketchedOut
Getting Started
Bi-cycle uses generators and provides an interface to modify the immutable index.
import Bicycle from 'bi-cycle';
const { next } = Bicycle();
nextButton.addEventListener('click', next);
You can destructure a handful of functions — first
, previous
, next
, last
— for traversing the generator — each invocation to Bicycle
will yield a new generator and therefore you can quite easily have multiple instances. You can also use current
to determine the current index, and goto
which accepts a number
parameter which navigates to a specific index.
With the Bicycle
function you can pass startIndex
and maxItems
— by default Infinity
. As Bi-cycle has infinite cycling specifying a maxItems
will constrain the value to the range specified — 0
to maxItems
.