@su-labs/scroll-spy 21.0.4 โ†’ 21.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +157 -0
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [21.0.5] - 2026-02-04
9
+
10
+ ### Changed
11
+ - Update README.md
12
+
8
13
  ## [21.0.4] - 2026-02-03
9
14
 
10
15
  ### Changed
@@ -16,7 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
21
  - Projects using Angular 20 or below should continue using version 1.0.3.
17
22
  - This release maintains full backward compatibility with the 1.x API - only the Angular version requirement has changed.
18
23
 
19
-
20
24
  ## [1.0.2] - 2025-08-30
21
25
 
22
26
  ### Fixed
package/README.md CHANGED
@@ -1,7 +1,45 @@
1
1
  # ScrollSpy
2
2
 
3
+ `@su-labs/scroll-spy`
4
+
5
+ ![Angular](https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white)
6
+ ![Angular Version](https://img.shields.io/badge/Angular-v21-DD0031?style=for-the-badge&logo=angular&logoColor=white)
7
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
8
+ ![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)
9
+ ![NPM](https://img.shields.io/badge/NPM-CB3837?style=for-the-badge&logo=npm&logoColor=white)
10
+ ![Size](https://img.shields.io/badge/Size-Small-green.svg?style=for-the-badge)
11
+ ![Downloads](https://img.shields.io/npm/dt/@su-labs/scroll-spy?style=for-the-badge)
12
+ ![Version](https://img.shields.io/npm/v/@su-labs/scroll-spy?style=for-the-badge)
13
+
3
14
  A lightweight Angular service and directive for managing active sections based on scroll position. Easily track which section of a page is currently visible and update your UI accordingly. Perfect for navigation menus, table of contents, or one-page scroll applications.
4
15
 
16
+ ## ๐Ÿ“š Table of Contents
17
+
18
+ - [Why Use This Library?](#-why-use-this-library)
19
+ - [Features](#features)
20
+ - [Installation](#installation)
21
+ - [Quick Start](#-quick-start)
22
+ - [Usage](#usage)
23
+ - [API Reference](#-api-reference)
24
+ - [How It Works](#how-it-works)
25
+ - [Browser Compatibility](#-browser-compatibility)
26
+ - [Related Libraries](#-related-libraries)
27
+ - [Troubleshooting](#-troubleshooting)
28
+ - [Support](#-support)
29
+ - [Contributing](#contributing)
30
+ - [License](#license)
31
+
32
+ ## ๐Ÿ’ก Why Use This Library?
33
+
34
+ - ๐ŸŽฏ **Lightweight** - Minimal bundle size
35
+ - โšก **Reactive** - Built with Angular Signals
36
+ - ๐Ÿš€ **Performant** - Uses IntersectionObserver API
37
+ - ๐ŸŽจ **Flexible** - Works with any layout
38
+ - ๐Ÿ”’ **Type-Safe** - Full TypeScript support
39
+ - ๐Ÿ“ฆ **Zero Dependencies** - No bloat
40
+ - ๐Ÿงช **Well Tested** - Comprehensive test coverage
41
+ - ๐Ÿ“ **Well Documented** - Clear examples and API docs
42
+
5
43
  ## Features
6
44
 
7
45
  - Track the currently visible section on the page
@@ -9,6 +47,7 @@ A lightweight Angular service and directive for managing active sections based o
9
47
  - Works with multiple sections
10
48
  - Optional directive to automatically update the active section using IntersectionObserver
11
49
  - Fully modular: use the service alone, or combine with the directive for automatic detection
50
+ - Configurable intersection thresholds
12
51
 
13
52
  ## Installation
14
53
 
@@ -26,6 +65,39 @@ This library requires the following peer dependencies:
26
65
  npm install @angular/common@^21 @angular/core@^21
27
66
  ```
28
67
 
68
+ ## ๐Ÿš€ Quick Start
69
+
70
+ ```typescript
71
+ // 1. Install
72
+ npm install @su-labs/scroll-spy
73
+
74
+ // 2. Add directive to your sections
75
+ @for (section of sections; track section.id) {
76
+ <section [id]="section.id" [appScrollSpy]="section.id">
77
+ <h2>{{ section.name }}</h2>
78
+ </section>
79
+ }
80
+
81
+ // 3. Track active section in navigation
82
+ @for (section of sections; track section.id) {
83
+ <a
84
+ [href]="'#' + section.id"
85
+ [class.active]="activeSection() === section.id"
86
+ >
87
+ {{ section.name }}
88
+ </a>
89
+ }
90
+
91
+ // 4. Inject service in component
92
+ import { Component, inject } from '@angular/core';
93
+ import { ScrollSpyService } from '@su-labs/scroll-spy';
94
+
95
+ export class AppComponent {
96
+ scrollSpyService = inject(ScrollSpyService);
97
+ activeSection = this.scrollSpyService.activeSection;
98
+ }
99
+ ```
100
+
29
101
  ## Usage
30
102
 
31
103
  ### Using the service and directive
@@ -82,10 +154,95 @@ export class ScrollExampleComponent {
82
154
  }
83
155
  ```
84
156
 
157
+ ## ๐Ÿ“– API Reference
158
+
159
+ ### Service (ScrollSpyService)
160
+
161
+ #### Signals
162
+
163
+ | Signal | Type | Description |
164
+ |--------|------|-------------|
165
+ | `activeSection()` | `string \| null` | ID of currently active section |
166
+
167
+ #### Methods
168
+
169
+ | Method | Parameters | Description |
170
+ |--------|------------|-------------|
171
+ | `setActiveSection(id)` | `string` | Manually set active section |
172
+
173
+ ### Directive (ScrollSpyDirective)
174
+
175
+ #### Inputs
176
+
177
+ | Input | Type | Description |
178
+ |-------|------|-------------|
179
+ | `appScrollSpy` | `string` | Section ID to track |
180
+
181
+ #### How to Use
182
+
183
+ ```html
184
+ <section [appScrollSpy]="'section-id'">
185
+ <!-- Your content -->
186
+ </section>
187
+ ```
188
+
85
189
  ## How It Works
86
190
 
87
191
  The `ScrollSpyDirective` uses the browser's native [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to efficiently monitor when elements enter or exit the viewport. It's configured to trigger when a tracked section is roughly in the vertical center of the screen, providing a smooth and accurate "spy" effect.
88
192
 
193
+ **Key Benefits:**
194
+ - ๐Ÿš€ **Performance**: No scroll event listeners needed
195
+ - ๐ŸŽฏ **Accuracy**: Precise intersection detection
196
+ - โšก **Efficiency**: Browser-native implementation
197
+ - ๐Ÿ”‹ **Battery Friendly**: Optimized for mobile devices
198
+
199
+ ## ๐ŸŒ Browser Compatibility
200
+
201
+ Works in all modern browsers that support:
202
+ - โœ… IntersectionObserver API
203
+ - โœ… Angular 21+
204
+ - โœ… ES2022+
205
+
206
+ | Browser | Version |
207
+ |---------|---------|
208
+ | Chrome | โ‰ฅ 58 |
209
+ | Firefox | โ‰ฅ 55 |
210
+ | Safari | โ‰ฅ 12.1 |
211
+ | Edge | โ‰ฅ 16 |
212
+
213
+ ## ๐Ÿ”— Related Libraries
214
+
215
+ Part of the **@su-labs** suite:
216
+
217
+ - ๐Ÿ‘€ [@su-labs/visit-tracker](https://www.npmjs.com/package/@su-labs/visit-tracker) - User visit tracking
218
+ - ๐ŸŽจ [@su-labs/theme](https://www.npmjs.com/package/@su-labs/theme) - Theme management with dark mode support
219
+ - ๐Ÿ”” [@su-labs/notifications](https://www.npmjs.com/package/@su-labs/notifications) - Toast notification system
220
+ - ๐Ÿ“ [@su-labs/font-size](https://www.npmjs.com/package/@su-labs/font-size) - Accessible font size controls
221
+
222
+ ## ๐Ÿ”ง Troubleshooting
223
+
224
+ ### Active section not updating?
225
+
226
+ Make sure you've added the `appScrollSpy` directive to all sections you want to track.
227
+
228
+ ### Multiple sections active at once?
229
+
230
+ This shouldn't happen with the default configuration. Check that section IDs are unique.
231
+
232
+ ### Directive not found?
233
+
234
+ Make sure you've imported `ScrollSpyDirective` in your component's imports array (for standalone components).
235
+
236
+ ### TypeScript errors?
237
+
238
+ Ensure you have Angular 21+ and TypeScript 5.7+ installed.
239
+
240
+ ## ๐Ÿ’ฌ Support
241
+
242
+ - ๐Ÿ› Found a bug? [Open an issue](https://github.com/Greezaaa/settings-utils-lib/issues)
243
+ - ๐Ÿ’ก Have a feature request? [Start a discussion](https://github.com/Greezaaa/settings-utils-lib/discussions)
244
+ - โญ Like this library? [Give it a star!](https://github.com/Greezaaa/settings-utils-lib)
245
+
89
246
  ## Contributing
90
247
 
91
248
  If you find any bugs or have feature requests, please open an issue or submit a pull request on our [**GitHub repository**](https://github.com/Greezaaa/settings-utils-lib.git).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@su-labs/scroll-spy",
3
- "version": "21.0.4",
3
+ "version": "21.0.5",
4
4
  "description": "An Angular scroll spy utility based on IntersectionObserver for tracking active sections or menu items.",
5
5
  "keywords": [
6
6
  "angular",