{"_id":"@cwavasape/doom-scroller","name":"@cwavasape/doom-scroller","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@cwavasape/doom-scroller","type":"module","license":"MIT","version":"0.0.1","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"devDependencies":{"@vitest/coverage-v8":"^2.1.3","jsdom":"^25.0.1","tsup":"^8.3.0","typescript":"^5.0.0","vitest":"^2.1.3"},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts","lint":"tsc","test":"vitest","test:coverage":"vitest run --coverage","test:ui":"vitest --ui"},"_id":"@cwavasape/doom-scroller@0.0.1","description":"A high-performance, smooth scroll detection library for advanced scroll-based interactions. Part of the CWAVASAPE project.","_integrity":"sha512-Du/RB/0YnHeRFTVBd1mmUsLzbDa1xowQmQuwGCigpfI2NS1osatjOIhT0mSeI+HAhJP2FahYDAEUr1QCOo3ksw==","_resolved":"/tmp/3e8e5025cbbeb70e520766b7381a2d21/cwavasape-doom-scroller-0.0.1.tgz","_from":"file:cwavasape-doom-scroller-0.0.1.tgz","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Du/RB/0YnHeRFTVBd1mmUsLzbDa1xowQmQuwGCigpfI2NS1osatjOIhT0mSeI+HAhJP2FahYDAEUr1QCOo3ksw==","shasum":"aa94f3b6190964ea31e3bb820946257db95f2fb1","tarball":"https://registry.npmjs.org/@cwavasape/doom-scroller/-/doom-scroller-0.0.1.tgz","fileCount":7,"unpackedSize":40883,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFG9oVwwG7BQADNloceNOfe2s8AcpHc306Wi5r13i22lAiEA5Bp7PssSeR3RsqUqhKADy7Mp6pnKxp/z7+PpOKtvCzk="}]},"_npmUser":{"name":"fcastrovilli","email":"francesco.castrovilli95@gmail.com"},"directories":{},"maintainers":[{"name":"fcastrovilli","email":"francesco.castrovilli95@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/doom-scroller_0.0.1_1729780839043_0.5116558099205624"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-24T14:40:38.934Z","0.0.1":"2024-10-24T14:40:39.233Z","modified":"2024-10-24T14:40:39.560Z"},"maintainers":[{"name":"fcastrovilli","email":"francesco.castrovilli95@gmail.com"}],"description":"A high-performance, smooth scroll detection library for advanced scroll-based interactions. Part of the CWAVASAPE project.","license":"MIT","readme":"# DOOM SCROLLER\n\nA high-performance, smooth scroll detection library for advanced scroll-based interactions. Part of the CWAVASAPE project.\n\n[![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)\n[![Turborepo](https://img.shields.io/badge/Turborepo-EF4444?style=flat-square&logo=turborepo&logoColor=white)](https://turbo.build/)\n[![npm version](https://img.shields.io/npm/v/@cwavasape/doom-scroller.svg?style=flat-square)](https://www.npmjs.com/package/@cwavasape/doom-scroller)\n[![npm downloads](https://img.shields.io/npm/dm/@cwavasape/doom-scroller.svg?style=flat-square)](https://www.npmjs.com/package/@cwavasape/doom-scroller)\n\n## Features\n\n- 🎯 Precise scroll direction detection\n- 📊 Real-time velocity tracking\n- 🔄 Smooth scroll delta normalization\n- ⚡ High-performance animation frame updates\n- 🎛️ Configurable sensitivity and smoothing\n- 📱 Cross-browser wheel event normalization\n- 💪 Fully typed TypeScript API\n\n## Installation\n\nInstall the package using your preferred package manager:\n\n```bash\n# Using npm\nnpm install @cwavasape/doom-scroller\n\n# Using yarn\nyarn add @cwavasape/doom-scroller\n\n# Using pnpm\npnpm add @cwavasape/doom-scroller\n```\n\n## Quick Start\n\n```typescript\nimport { DoomScroller } from \"@cwavasape/doom-scroller\";\n\n// Create a new instance\nconst scroller = new DoomScroller({\n  smoothingFactor: 0.2, // Lower = smoother but more latency\n  speedMultiplier: 1.5, // Higher = more sensitive\n  directionThreshold: 0.1, // Lower = more responsive to direction changes\n});\n\n// Initialize scroll detection\nscroller.init();\n\n// Subscribe to scroll state updates\nconst unsubscribe = scroller.subscribe((state) => {\n  console.log(\"Scroll direction:\", state.direction);\n  console.log(\"Scroll velocity:\", state.velocity);\n\n  if (state.direction.y === \"down\") {\n    // Handle downward scroll\n  }\n});\n\n// Cleanup when done\nscroller.destroy();\n```\n\n## Development\n\nIf you're working on the CWAVASAPE project locally and want to develop or modify the DOOM SCROLLER package:\n\n### Clone the repository\n\n```bash\ngit clone https://github.com/cwavasapee/cwavasape.git\ncd cwavasape\n```\n\n### Install dependencies\n\n```bash\npnpm install\n```\n\n### Link the package locally in your `package.json`\n\n```json\n{\n  \"dependencies\": {\n    \"@cwavasape/doom-scroller\": \"workspace:*\"\n  }\n}\n```\n\n### Run the development environment\n\n```bash\npnpm dev\n```\n\nThis will start the Turborepo development environment with hot reloading for both the package and any apps consuming it.\n\n## API Reference\n\n### `DoomScroller`\n\nMain class for scroll detection and state management.\n\n#### Constructor Options\n\n```typescript\ninterface DoomScrollerOptions {\n  /** Multiplier for scroll speed. Default: 1 */\n  speedMultiplier?: number;\n  /** Number of samples to keep for smoothing. Default: 5 */\n  sampleSize?: number;\n  /** Minimum velocity to register as movement. Default: 0.1 */\n  minVelocity?: number;\n  /** Threshold for direction change detection. Default: 0.15 */\n  directionThreshold?: number;\n  /** Factor for smoothing scroll movements. Default: 0.3 */\n  smoothingFactor?: number;\n  /** Time in ms to wait before considering scroll ended. Default: 150 */\n  debounceTime?: number;\n}\n```\n\n#### Methods\n\n- `init()`: Initialize scroll detection\n- `destroy()`: Cleanup resources and event listeners\n- `subscribe(callback: (state: ScrollState) => void): () => void`: Subscribe to scroll state updates\n\n#### Scroll State Interface\n\n```typescript\ninterface ScrollState {\n  /** Whether scrolling is currently active */\n  isScrolling: boolean;\n  /** Current velocity in pixels per millisecond */\n  velocity: {\n    x: number;\n    y: number;\n  };\n  /** Current scroll direction state */\n  direction: {\n    x: \"left\" | \"right\" | \"none\";\n    y: \"up\" | \"down\" | \"none\";\n  };\n  /** Change in scroll position since last update */\n  delta: {\n    x: number;\n    y: number;\n  };\n  /** Raw scroll values from the wheel event */\n  rawScroll: {\n    x: number;\n    y: number;\n  };\n}\n```\n\n## Advanced Usage\n\n### Smooth Scrolling Animation\n\n```typescript\nconst scroller = new DoomScroller({\n  smoothingFactor: 0.1, // Very smooth\n  speedMultiplier: 1.2,\n});\n\nscroller.init();\n\nlet translateY = 0;\nconst content = document.querySelector(\".content\");\n\nscroller.subscribe((state) => {\n  if (!state.isScrolling) return;\n\n  // Apply smooth transform based on velocity\n  translateY += state.velocity.y * 16; // 16ms frame time\n  content?.style.transform = `translateY(${translateY}px)`;\n});\n```\n\n### Directional UI Updates\n\n```typescript\nconst scroller = new DoomScroller({\n  directionThreshold: 0.1, // Responsive to direction changes\n});\n\nscroller.init();\n\nconst header = document.querySelector(\".header\");\n\nscroller.subscribe((state) => {\n  if (state.direction.y === \"up\") {\n    header?.classList.remove(\"header--hidden\");\n  } else if (state.direction.y === \"down\" && state.velocity.y > 0.5) {\n    header?.classList.add(\"header--hidden\");\n  }\n});\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Related Packages\n\nOther packages in the CWAVASAPE project:\n\n- `@cwavasape/web` - Main web application built with SvelteKit 5\n","readmeFilename":"README.md"}