@su-labs/scroll-spy 21.0.4 → 22.0.0

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ 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
+ ## [22.0.0] - 2026-11-04
9
+
10
+ ### Changed
11
+ - Upgrade to Angular 22 (peer dependencies now `^22.0.0`)
12
+ - Remove emojis from README.md
13
+
14
+ ## [21.0.5] - 2026-02-04
15
+
16
+ ### Changed
17
+ - Update README.md
18
+
8
19
  ## [21.0.4] - 2026-02-03
9
20
 
10
21
  ### Changed
@@ -16,7 +27,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
27
  - Projects using Angular 20 or below should continue using version 1.0.3.
17
28
  - This release maintains full backward compatibility with the 1.x API - only the Angular version requirement has changed.
18
29
 
19
-
20
30
  ## [1.0.2] - 2025-08-30
21
31
 
22
32
  ### 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-v22-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
 
@@ -23,7 +62,40 @@ npm install @su-labs/scroll-spy
23
62
  This library requires the following peer dependencies:
24
63
 
25
64
  ```sh
26
- npm install @angular/common@^21 @angular/core@^21
65
+ npm install @angular/common@^22 @angular/core@^22
66
+ ```
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
+ }
27
99
  ```
28
100
 
29
101
  ## Usage
@@ -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 22+
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 22+ and TypeScript 6.0+ 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).
@@ -1,84 +1,81 @@
1
- import * as i0 from '@angular/core';
2
- import { signal, Injectable, inject, ElementRef, Input, Directive } from '@angular/core';
3
-
4
- /**
5
- * Service that keeps track of the currently active section while scrolling.
6
- * Can be injected into components to react to section changes.
7
- */
8
- class ScrollSpyService {
9
- /** ID of the currently visible section */
10
- activeSection = signal('', ...(ngDevMode ? [{ debugName: "activeSection" }] : []));
11
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
12
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyService, providedIn: 'root' });
13
- }
14
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyService, decorators: [{
15
- type: Injectable,
16
- args: [{ providedIn: 'root' }]
17
- }] });
18
-
19
- /**
20
- * Directive that observes an element's visibility on the screen
21
- * and updates ScrollSpyService.activeSection when it enters the viewport.
22
- *
23
- * Usage:
24
- * <section [appScrollSpy]="'home'">...</section>
25
- */
26
- class ScrollSpyDirective {
27
- /** ID of the observed section */
28
- sectionId;
29
- el = inject(ElementRef);
30
- scrollSpy = inject(ScrollSpyService);
31
- ngOnInit() {
32
- const observer = new IntersectionObserver((entries) => {
33
- for (const entry of entries) {
34
- if (entry.isIntersecting) {
35
- this.scrollSpy.activeSection.set(this.sectionId);
36
- }
37
- }
38
- }, {
39
- // The viewport used to check visibility.
40
- // `null` means the browser viewport is used.
41
- root: null,
42
- // How much of the element needs to be visible to trigger the observer.
43
- // `0` means it triggers as soon as even one pixel is visible within the root + rootMargin.
44
- threshold: 0,
45
- // rootMargin defines an offset around the viewport that affects when the observer triggers.
46
- // Format: 'top right bottom left'
47
- // In this case:
48
- // - top: -50%
49
- // - right: 0px
50
- // - bottom: -50%
51
- // - left: 0px
52
- //
53
- // This means the observer will consider the element "intersecting" only when
54
- // it is roughly in the vertical center of the viewport.
55
- // It's perfect for scroll-spy behavior, because it triggers when the section
56
- // is the main focus on the screen, rather than just appearing at the top.
57
- rootMargin: '-50% 0px -50% 0px',
58
- });
59
- observer.observe(this.el.nativeElement);
60
- }
61
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
62
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.2", type: ScrollSpyDirective, isStandalone: true, selector: "[appScrollSpy]", inputs: { sectionId: ["appScrollSpy", "sectionId"] }, ngImport: i0 });
63
- }
64
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyDirective, decorators: [{
65
- type: Directive,
66
- args: [{
67
- selector: '[appScrollSpy]',
68
- standalone: true,
69
- }]
70
- }], propDecorators: { sectionId: [{
71
- type: Input,
72
- args: ['appScrollSpy']
73
- }] } });
74
-
75
- /*
76
- * Public API Surface of scroll-spy
77
- */
78
-
79
- /**
80
- * Generated bundle index. Do not edit.
81
- */
82
-
1
+ import * as i0 from "@angular/core";
2
+ import { Directive, ElementRef, Injectable, Input, inject, signal } from "@angular/core";
3
+ var ScrollSpyService = class ScrollSpyService {
4
+ activeSection = signal("", ...ngDevMode ? [{ debugName: "activeSection" }] : /* istanbul ignore next */ []);
5
+ static ɵfac = i0.ɵɵngDeclareFactory({
6
+ minVersion: "12.0.0",
7
+ version: "22.2.4",
8
+ ngImport: i0,
9
+ type: ScrollSpyService,
10
+ deps: [],
11
+ target: i0.ɵɵFactoryTarget.Injectable
12
+ });
13
+ static ɵprov = i0.ɵɵngDeclareInjectable({
14
+ minVersion: "12.0.0",
15
+ version: "22.2.4",
16
+ ngImport: i0,
17
+ type: ScrollSpyService,
18
+ providedIn: "root"
19
+ });
20
+ };
21
+ i0.ɵɵngDeclareClassMetadata({
22
+ minVersion: "12.0.0",
23
+ version: "22.2.4",
24
+ ngImport: i0,
25
+ type: ScrollSpyService,
26
+ decorators: [{
27
+ type: Injectable,
28
+ args: [{ providedIn: "root" }]
29
+ }]
30
+ });
31
+ var ScrollSpyDirective = class ScrollSpyDirective {
32
+ sectionId;
33
+ el = inject(ElementRef);
34
+ scrollSpy = inject(ScrollSpyService);
35
+ ngOnInit() {
36
+ new IntersectionObserver((entries) => {
37
+ for (const entry of entries) if (entry.isIntersecting) this.scrollSpy.activeSection.set(this.sectionId);
38
+ }, {
39
+ root: null,
40
+ threshold: 0,
41
+ rootMargin: "-50% 0px -50% 0px"
42
+ }).observe(this.el.nativeElement);
43
+ }
44
+ static ɵfac = i0.ɵɵngDeclareFactory({
45
+ minVersion: "12.0.0",
46
+ version: "22.2.4",
47
+ ngImport: i0,
48
+ type: ScrollSpyDirective,
49
+ deps: [],
50
+ target: i0.ɵɵFactoryTarget.Directive
51
+ });
52
+ static ɵdir = i0.ɵɵngDeclareDirective({
53
+ minVersion: "14.0.0",
54
+ version: "22.2.4",
55
+ type: ScrollSpyDirective,
56
+ isStandalone: true,
57
+ selector: "[appScrollSpy]",
58
+ inputs: { sectionId: ["appScrollSpy", "sectionId"] },
59
+ ngImport: i0
60
+ });
61
+ };
62
+ i0.ɵɵngDeclareClassMetadata({
63
+ minVersion: "12.0.0",
64
+ version: "22.2.4",
65
+ ngImport: i0,
66
+ type: ScrollSpyDirective,
67
+ decorators: [{
68
+ type: Directive,
69
+ args: [{
70
+ selector: "[appScrollSpy]",
71
+ standalone: true
72
+ }]
73
+ }],
74
+ propDecorators: { sectionId: [{
75
+ type: Input,
76
+ args: ["appScrollSpy"]
77
+ }] }
78
+ });
83
79
  export { ScrollSpyDirective, ScrollSpyService };
84
- //# sourceMappingURL=su-labs-scroll-spy.mjs.map
80
+
81
+ //# sourceMappingURL=su-labs-scroll-spy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"su-labs-scroll-spy.mjs","sources":["../../../../projects/su-labs/scroll-spy/src/lib/scroll-spy.service.ts","../../../../projects/su-labs/scroll-spy/src/lib/scroll-spy.directive.ts","../../../../projects/su-labs/scroll-spy/src/public-api.ts","../../../../projects/su-labs/scroll-spy/src/su-labs-scroll-spy.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\n\n/**\n * Service that keeps track of the currently active section while scrolling.\n * Can be injected into components to react to section changes.\n */\n@Injectable({ providedIn: 'root' })\nexport class ScrollSpyService {\n /** ID of the currently visible section */\n activeSection = signal<string>('');\n}\n","import { Directive, ElementRef, inject, Input, OnInit } from '@angular/core';\nimport { ScrollSpyService } from './scroll-spy.service';\n\n/**\n * Directive that observes an element's visibility on the screen\n * and updates ScrollSpyService.activeSection when it enters the viewport.\n *\n * Usage:\n * <section [appScrollSpy]=\"'home'\">...</section>\n */\n@Directive({\n selector: '[appScrollSpy]',\n standalone: true,\n})\nexport class ScrollSpyDirective implements OnInit {\n /** ID of the observed section */\n @Input('appScrollSpy') sectionId!: string;\n\n private readonly el = inject(ElementRef);\n private readonly scrollSpy = inject(ScrollSpyService);\n\n ngOnInit() {\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n this.scrollSpy.activeSection.set(this.sectionId);\n }\n }\n },\n {\n // The viewport used to check visibility.\n // `null` means the browser viewport is used.\n root: null,\n // How much of the element needs to be visible to trigger the observer.\n // `0` means it triggers as soon as even one pixel is visible within the root + rootMargin.\n threshold: 0,\n // rootMargin defines an offset around the viewport that affects when the observer triggers.\n // Format: 'top right bottom left'\n // In this case:\n // - top: -50%\n // - right: 0px\n // - bottom: -50%\n // - left: 0px\n //\n // This means the observer will consider the element \"intersecting\" only when\n // it is roughly in the vertical center of the viewport.\n // It's perfect for scroll-spy behavior, because it triggers when the section\n // is the main focus on the screen, rather than just appearing at the top.\n rootMargin: '-50% 0px -50% 0px',\n },\n );\n observer.observe(this.el.nativeElement);\n }\n}\n","/*\n * Public API Surface of scroll-spy\n */\n\nexport * from './lib/scroll-spy.service';\nexport * from './lib/scroll-spy.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEA;;;AAGG;MAEU,gBAAgB,CAAA;;AAE3B,IAAA,aAAa,GAAG,MAAM,CAAS,EAAE,yDAAC;uGAFvB,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAhB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cADH,MAAM,EAAA,CAAA;;2FACnB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACHlC;;;;;;AAMG;MAKU,kBAAkB,CAAA;;AAEN,IAAA,SAAS;AAEf,IAAA,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;AACvB,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAErD,QAAQ,GAAA;QACN,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,KAAI;AACV,YAAA,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;AAC3B,gBAAA,IAAI,KAAK,CAAC,cAAc,EAAE;oBACxB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;gBAClD;YACF;AACF,QAAA,CAAC,EACD;;;AAGE,YAAA,IAAI,EAAE,IAAI;;;AAGV,YAAA,SAAS,EAAE,CAAC;;;;;;;;;;;;;AAaZ,YAAA,UAAU,EAAE,mBAAmB;AAChC,SAAA,CACF;QACD,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;IACzC;uGAvCW,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAlB,kBAAkB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,gBAAA,EAAA,MAAA,EAAA,EAAA,SAAA,EAAA,CAAA,cAAA,EAAA,WAAA,CAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAJ9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,UAAU,EAAE,IAAI;AACjB,iBAAA;;sBAGE,KAAK;uBAAC,cAAc;;;AChBvB;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"su-labs-scroll-spy.mjs","names":[],"sources":["../../../../projects/su-labs/scroll-spy/src/lib/scroll-spy.service.ts","../../../../projects/su-labs/scroll-spy/src/lib/scroll-spy.directive.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\n\n/**\n * Service that keeps track of the currently active section while scrolling.\n * Can be injected into components to react to section changes.\n */\n@Injectable({ providedIn: 'root' })\nexport class ScrollSpyService {\n /** ID of the currently visible section */\n activeSection = signal<string>('');\n}\n","import { Directive, ElementRef, inject, Input, OnInit } from '@angular/core';\nimport { ScrollSpyService } from './scroll-spy.service';\n\n/**\n * Directive that observes an element's visibility on the screen\n * and updates ScrollSpyService.activeSection when it enters the viewport.\n *\n * Usage:\n * <section [appScrollSpy]=\"'home'\">...</section>\n */\n@Directive({\n selector: '[appScrollSpy]',\n standalone: true,\n})\nexport class ScrollSpyDirective implements OnInit {\n /** ID of the observed section */\n @Input('appScrollSpy') sectionId!: string;\n\n private readonly el = inject(ElementRef);\n private readonly scrollSpy = inject(ScrollSpyService);\n\n ngOnInit() {\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n this.scrollSpy.activeSection.set(this.sectionId);\n }\n }\n },\n {\n // The viewport used to check visibility.\n // `null` means the browser viewport is used.\n root: null,\n // How much of the element needs to be visible to trigger the observer.\n // `0` means it triggers as soon as even one pixel is visible within the root + rootMargin.\n threshold: 0,\n // rootMargin defines an offset around the viewport that affects when the observer triggers.\n // Format: 'top right bottom left'\n // In this case:\n // - top: -50%\n // - right: 0px\n // - bottom: -50%\n // - left: 0px\n //\n // This means the observer will consider the element \"intersecting\" only when\n // it is roughly in the vertical center of the viewport.\n // It's perfect for scroll-spy behavior, because it triggers when the section\n // is the main focus on the screen, rather than just appearing at the top.\n rootMargin: '-50% 0px -50% 0px',\n },\n );\n observer.observe(this.el.nativeElement);\n }\n}\n"],"mappings":";;AAOA,IAAa,mBAAb,MAAa,iBAAgB;CAE3B,gBAAgB,OAAe,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,gBAAA,CAAA,+BAAA,CAAA,CAAA;CAFvB,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAgB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAhB,OAAA,QAAA,GAAA,sBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAgB,YADH;CAAM,CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAgB,YAAA,CAAA;EAD5B,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE;;;ACQlC,IAAa,qBAAb,MAAa,mBAAkB;CAEN;CAEN,KAAK,OAAO,UAAU;CACtB,YAAY,OAAO,gBAAgB;CAEpD,WAAQ;EA+BN,IA9BqB,sBAClB,YAAW;GACV,KAAK,MAAM,SAAS,SAClB,IAAI,MAAM,gBACR,KAAK,UAAU,cAAc,IAAI,KAAK,SAAS;EAGrD,GACA;GAGE,MAAM;GAGN,WAAW;GAaX,YAAY;EACb,CAEH,CAAA,CAAS,QAAQ,KAAK,GAAG,aAAa;CACxC;CAvCW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAkB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAlB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAkB,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,WAAA,CAAA,gBAAA,WAAA,EAAA;EAAA,UAAA;CAAA,CAAA;;AAAlB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAkB,YAAA,CAAA;EAJ9B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,YAAY;EACb,CAAA;;;EAGE,MAAA;EAAM,MAAA,CAAA,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@su-labs/scroll-spy",
3
- "version": "21.0.4",
3
+ "version": "22.0.0",
4
4
  "description": "An Angular scroll spy utility based on IntersectionObserver for tracking active sections or menu items.",
5
5
  "keywords": [
6
6
  "angular",
@@ -29,8 +29,8 @@
29
29
  "url": "https://github.com/Greezaaa/settings-utils-lib/issues"
30
30
  },
31
31
  "peerDependencies": {
32
- "@angular/common": "^21.0.0",
33
- "@angular/core": "^21.0.0"
32
+ "@angular/common": "^22.0.0",
33
+ "@angular/core": "^22.0.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "tslib": "^2.3.0"
@@ -47,5 +47,6 @@
47
47
  "types": "./types/su-labs-scroll-spy.d.ts",
48
48
  "default": "./fesm2022/su-labs-scroll-spy.mjs"
49
49
  }
50
- }
50
+ },
51
+ "type": "module"
51
52
  }
@@ -1,17 +1,15 @@
1
- import * as i0 from '@angular/core';
2
- import { OnInit } from '@angular/core';
3
-
1
+ import * as i0 from "@angular/core";
2
+ import { OnInit } from "@angular/core";
4
3
  /**
5
4
  * Service that keeps track of the currently active section while scrolling.
6
5
  * Can be injected into components to react to section changes.
7
6
  */
8
- declare class ScrollSpyService {
9
- /** ID of the currently visible section */
10
- activeSection: i0.WritableSignal<string>;
11
- static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyService, never>;
12
- static ɵprov: i0.ɵɵInjectableDeclaration<ScrollSpyService>;
7
+ export declare class ScrollSpyService {
8
+ /** ID of the currently visible section */
9
+ activeSection: import("@angular/core").WritableSignal<string>;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyService, never>;
11
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
13
12
  }
14
-
15
13
  /**
16
14
  * Directive that observes an element's visibility on the screen
17
15
  * and updates ScrollSpyService.activeSection when it enters the viewport.
@@ -19,14 +17,17 @@ declare class ScrollSpyService {
19
17
  * Usage:
20
18
  * <section [appScrollSpy]="'home'">...</section>
21
19
  */
22
- declare class ScrollSpyDirective implements OnInit {
23
- /** ID of the observed section */
24
- sectionId: string;
25
- private readonly el;
26
- private readonly scrollSpy;
27
- ngOnInit(): void;
28
- static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyDirective, never>;
29
- static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollSpyDirective, "[appScrollSpy]", never, { "sectionId": { "alias": "appScrollSpy"; "required": false; }; }, {}, never, never, true, never>;
30
- }
31
-
32
- export { ScrollSpyDirective, ScrollSpyService };
20
+ export declare class ScrollSpyDirective implements OnInit {
21
+ /** ID of the observed section */
22
+ sectionId: string;
23
+ private readonly el;
24
+ private readonly scrollSpy;
25
+ ngOnInit(): void;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyDirective, never>;
27
+ static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollSpyDirective, "[appScrollSpy]", never, {
28
+ "sectionId": {
29
+ "alias": "appScrollSpy";
30
+ "required": false;
31
+ };
32
+ }, {}, never, never, true, never>;
33
+ }