|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Guide for coding agents working in the **react-scroll-parallax** repository. |
| 4 | + |
| 5 | +## Project |
| 6 | + |
| 7 | +- **Package:** `react-scroll-parallax` (v4 beta — WAAPI / ScrollTimeline) |
| 8 | +- **Peer deps:** React 16.8+ / 17 / 18 / 19 |
| 9 | +- **Install (v4):** `npm install react-scroll-parallax@beta` |
| 10 | +- **Build:** `pnpm build` (outputs to `dist/`) |
| 11 | +- **Tests:** `pnpm test` |
| 12 | + |
| 13 | +## Documentation for agents |
| 14 | + |
| 15 | +Prefer machine-readable docs over scraping the site: |
| 16 | + |
| 17 | +- Index: https://react-scroll-parallax.damnthat.tv/llms.txt |
| 18 | +- Full bundle: https://react-scroll-parallax.damnthat.tv/llms-full.txt |
| 19 | +- Per-page markdown: https://react-scroll-parallax.damnthat.tv/docs/v4/**/*.md |
| 20 | + |
| 21 | +Current docs target **v4 beta**. v3 docs remain on the site via the version dropdown. |
| 22 | + |
| 23 | +## Quick start |
| 24 | + |
| 25 | +```tsx |
| 26 | +import { ParallaxProvider, useParallax, Parallax } from 'react-scroll-parallax'; |
| 27 | + |
| 28 | +function App() { |
| 29 | + return ( |
| 30 | + <ParallaxProvider> |
| 31 | + <MyContent /> |
| 32 | + </ParallaxProvider> |
| 33 | + ); |
| 34 | +} |
| 35 | + |
| 36 | +function MyContent() { |
| 37 | + const { ref } = useParallax({ speed: -10 }); |
| 38 | + return ( |
| 39 | + <> |
| 40 | + <div ref={ref}>Hook example</div> |
| 41 | + <Parallax speed={10}> |
| 42 | + <div>Component example</div> |
| 43 | + </Parallax> |
| 44 | + </> |
| 45 | + ); |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +`<ParallaxProvider>` must wrap any tree that uses parallax hooks or components. |
| 50 | + |
| 51 | +## Key API |
| 52 | + |
| 53 | +| Topic | Doc | |
| 54 | +| --- | --- | |
| 55 | +| Setup | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/usage | |
| 56 | +| All props | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/parallax-props | |
| 57 | +| `useParallax` | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/hooks/use-parallax | |
| 58 | +| `useParallaxController` | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/hooks/use-parallax-controller | |
| 59 | +| `<Parallax>` | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/components/parallax-component | |
| 60 | +| `<ParallaxBanner>` | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/components/parallax-banner-component | |
| 61 | +| `<ParallaxProvider>` | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/components/parallax-provider | |
| 62 | +| Next.js App Router | https://react-scroll-parallax.damnthat.tv/docs/v4/usage/next-13 | |
| 63 | +| v3 → v4 migration | https://react-scroll-parallax.damnthat.tv/docs/v4/migration-guides/v3-migration-guide | |
| 64 | + |
| 65 | +## Source layout |
| 66 | + |
| 67 | +``` |
| 68 | +src/ |
| 69 | + index.ts # Public exports |
| 70 | + hooks/ # useParallax, useParallaxController |
| 71 | + components/ |
| 72 | + Parallax/ # <Parallax> component |
| 73 | + ParallaxBanner/ # <ParallaxBanner>, ParallaxBannerLayer |
| 74 | + ParallaxProvider/ # Context provider |
| 75 | + context/ParallaxContext.ts |
| 76 | +dist/ # Build output (published to npm) |
| 77 | +stories/ # Storybook examples |
| 78 | +documentation/ # Docusaurus docs site |
| 79 | +``` |
| 80 | + |
| 81 | +Underlying scroll engine: [parallax-controller](https://parallax-controller.damnthat.tv/docs/v2/intro). |
| 82 | + |
| 83 | +## Common pitfalls |
| 84 | + |
| 85 | +1. **Missing provider** — hooks/components throw or no-op without `<ParallaxProvider>`. |
| 86 | +2. **`<Parallax>` wrapper** — applies styles to its own wrapper `div`, not directly to children. |
| 87 | +3. **Cache updates** — call `parallaxController.update()` after route changes, image loads, or layout shifts. |
| 88 | +4. **Sticky elements** — parallax on sticky nodes causes issues; use `targetElement`, or fixed `startScroll` / `endScroll`. |
| 89 | +5. **v4 easing** — `easing` must be valid CSS/WAAPI timing values (not legacy preset strings like `easeInQuad`). |
| 90 | +6. **Horizontal scroll** — set `scrollAxis="horizontal"` on `<ParallaxProvider>`. |
0 commit comments