Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@reelkit/stories-core

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reelkit/stories-core

Framework-agnostic stories state machine, timer, and utilities for ReelKit

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

@reelkit/stories-core

npm Bundle size Star on GitHub

Framework-agnostic stories state machine for ReelKit. Story and group navigation (tap to advance within a group, swipe to switch between users), auto-advance timer with pause/resume, tap zone detection, and segmented progress bar with sliding window for 50+ stories. ~1.7 kB gzip.

Installation

npm install @reelkit/stories-core @reelkit/core

Quick Start

import {
  createStoriesController,
  getTapAction,
  getSegments,
} from '@reelkit/stories-core';

const controller = createStoriesController({
  groupCount: 5,
  storyCounts: [3, 4, 2, 5, 3],
});

// Navigate stories
controller.nextStory();
controller.prevStory();

// Switch between users
controller.nextGroup();
controller.prevGroup();

// Read state via signals
console.log(controller.state.activeGroupIndex.value); // 0
console.log(controller.state.activeStoryIndex.value); // 1

// Tap zone detection
getTapAction(50, 400); // 'prev' (left 30%)
getTapAction(300, 400); // 'next' (right 70%)

// Progress bar segments
const segments = getSegments(5, 2, 0.6);
// [completed, completed, active(60%), upcoming, upcoming]

Features

  • Stories controller with story and group navigation and boundary detection
  • Timer controller with requestAnimationFrame progress and pause/resume
  • Tap zone calculator (configurable left/right split ratio)
  • Segmented progress bar with sliding window overflow
  • Zero dependencies beyond @reelkit/core
  • Pure functions, fully tree-shakeable

API Reference

createStoriesController

ConfigTypeDefaultDescription
groupCountnumberrequiredNumber of story groups
storyCountsnumber[]requiredStories per group
initialGroupIndexnumber0Starting group index
initialStoryIndexnumber0Starting story index
defaultImageDurationnumber5000Default auto-advance (ms)
tapZoneSplitnumber0.3Left zone ratio (0-1)

StoriesController

Method / PropertyTypeDescription
state.activeGroupIndexSignal<number>Current group index
state.activeStoryIndexSignal<number>Current story index
state.isPausedSignal<boolean>Paused state
nextStory()voidAdvance to next story
prevStory()voidGo to previous story
nextGroup()voidSwitch to next user group
prevGroup()voidSwitch to previous user group
goToGroup(index)voidJump to specific group
pause()voidPause timer and auto-advance
resume()voidResume timer
dispose()voidClean up subscriptions

Events

EventTypeDescription
onStoryChange(groupIndex, storyIndex) => voidFired after story navigation
onGroupChange(groupIndex) => voidFired after group switch
onStoryViewed(groupIndex, storyIndex) => voidFired when a story is viewed
onComplete() => voidLast story of last group finished
onClose() => voidClose requested (boundary navigation)

getTapAction

function getTapAction(
  tapX: number,
  containerWidth: number,
  splitRatio?: number, // default: 0.3
): 'prev' | 'next';

getSegments

function getSegments(
  totalStories: number,
  activeIndex: number,
  timerProgress: number, // 0-1
): SegmentState[];

getVisibleWindow

function getVisibleWindow(
  totalStories: number,
  activeIndex: number,
  timerProgress: number,
  containerWidth: number,
  minSegmentWidth?: number, // default: 4
  gap?: number,
): VisibleWindow;

Types

type TapAction = 'prev' | 'next';

type SegmentStatus = 'completed' | 'active' | 'upcoming';

interface SegmentState {
  status: SegmentStatus;
  fillPercentage: number; // 0-100
}

interface VisibleWindow {
  startIndex: number;
  endIndex: number;
  segments: SegmentState[];
}

Documentation

API reference and guides at reelkit.dev.

Support

If ReelKit saved you some time, a star on GitHub would mean a lot.

Star on GitHub

License

MIT

Keywords

stories

FAQs

Package last updated on 27 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts