react-scroll-pkgs is a Turborepo monorepo containing React hooks and components for building scroll-linked UI animations. The project provides two npm packages:
- use-window-scroll-in-element - Primitive hook for tracking window position within an element
- react-scroll-flip-book - Scroll-linked flipbook animation component
Both packages are designed to work together but can be used independently.
React Hook that calculates where the window's top/bottom edge is positioned within a target element as the user scrolls. Returns both pixel values and percentage values (0-100%).
Installation:
npm install use-window-scroll-in-elementDocumentation: packages/use-window-scroll-in-element/README.md
npm: use-window-scroll-in-element
React component that creates scroll-linked flipbook animations by rendering sequential image frames on a canvas as the user scrolls. Built on top of use-window-scroll-in-element.
Installation:
npm install react-scroll-flip-bookDocumentation: packages/react-scroll-flip-book/README.md
import { useRef } from 'react';
import { useWindowScrollInElement } from 'use-window-scroll-in-element';
function MyComponent() {
const ref = useRef<HTMLDivElement>(null);
const { position, fraction } = useWindowScrollInElement(ref);
return (
<div ref={ref} style={{ height: '200vh' }}>
<p>Scroll progress: {(fraction.top * 100).toFixed(1)}%</p>
</div>
);
}import { ScrollFlipBook } from 'react-scroll-flip-book';
function App() {
const frames = Array.from({ length: 60 }, (_, i) => ({
webp: `/frames/frame-${String(i).padStart(4, '0')}.webp`,
jpg: `/frames/frame-${String(i).padStart(4, '0')}.jpg`,
}));
return (
<div style={{ height: '200vh' }}>
<ScrollFlipBook
defaultSource={{ framePaths: frames }}
style={{ width: '100%', height: '100vh' }}
/>
</div>
);
}This is a Turborepo monorepo with the following structure:
react-scroll-pkgs/
├── apps/
│ └── website/ # Demo/documentation site (Next.js)
├── packages/
│ ├── use-window-scroll-in-element/ # Published package
│ ├── react-scroll-flip-book/ # Published package
│ ├── eslint-config/ # Shared ESLint config
│ └── tsconfig/ # Shared TypeScript configs
├── .github/workflows/ # CI/CD workflows
├── docs/ # Developer documentation
└── scripts/ # Utility scripts
- Node.js 16+
- npm or yarn
# Install dependencies
npm install
# Build all packages
npm run build
# Run linting
npm run lint
# Run type checking
npm run typecheck
# Start demo website
npm run websiteturbo run build- Build all packages (respects dependencies)turbo run lint- Lint all packagesturbo run lint:fix- Auto-fix linting issuesturbo run typecheck- Type check all packages
- Live Demo - Interactive examples and visualizations hosted on Vercel
- GitHub Repository - Source code, issues, and pull requests
- Developer Documentation - Documentation index for developers and contributors
MIT © kubo-hide-kun
Contributions are welcome! Please see the GitHub repository for contribution guidelines.