@su-labs/scroll-spy 21.0.5 → 22.1.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 +20 -0
- package/README.md +43 -41
- package/fesm2022/su-labs-scroll-spy.mjs +82 -83
- package/fesm2022/su-labs-scroll-spy.mjs.map +1 -1
- package/package.json +6 -4
- package/types/su-labs-scroll-spy.d.ts +33 -21
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ 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.1.0] - 2026-11-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `ScrollSpyService.setActiveSection(id)` to set the active section manually (already documented in the README)
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Section observing moved to the framework-agnostic `@su-labs/core/scroll-spy`; `ScrollSpyDirective` now uses `observeSuScrollSpySection`
|
|
15
|
+
- Added `@su-labs/core` as a dependency
|
|
16
|
+
- README links to the `@su-labs/core` installation guides for non-Angular projects
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- `ScrollSpyDirective` now disconnects its IntersectionObserver when destroyed
|
|
20
|
+
- Repair table of contents links in README.md
|
|
21
|
+
|
|
22
|
+
## [22.0.0] - 2026-11-04
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Upgrade to Angular 22 (peer dependencies now `^22.0.0`)
|
|
26
|
+
- Remove emojis from README.md
|
|
27
|
+
|
|
8
28
|
## [21.0.5] - 2026-02-04
|
|
9
29
|
|
|
10
30
|
### Changed
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`@su-labs/scroll-spy`
|
|
4
4
|
|
|
5
5
|

|
|
6
|
-

|
|
7
7
|

|
|
8
8
|

|
|
9
9
|

|
|
@@ -13,32 +13,34 @@
|
|
|
13
13
|
|
|
14
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.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
> **Not using Angular?** The same scroll spy is available for React, Svelte and vanilla JavaScript in [`@su-labs/core`](https://www.npmjs.com/package/@su-labs/core). See the [installation guides](https://github.com/Greezaaa/settings-utils-lib/blob/main/docs/README.md).
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
## Table of Contents
|
|
19
|
+
|
|
20
|
+
- [Why Use This Library?](#why-use-this-library)
|
|
19
21
|
- [Features](#features)
|
|
20
22
|
- [Installation](#installation)
|
|
21
|
-
- [Quick Start](
|
|
23
|
+
- [Quick Start](#quick-start)
|
|
22
24
|
- [Usage](#usage)
|
|
23
|
-
- [API Reference](
|
|
25
|
+
- [API Reference](#api-reference)
|
|
24
26
|
- [How It Works](#how-it-works)
|
|
25
|
-
- [Browser Compatibility](
|
|
26
|
-
- [Related Libraries](
|
|
27
|
-
- [Troubleshooting](
|
|
28
|
-
- [Support](
|
|
27
|
+
- [Browser Compatibility](#browser-compatibility)
|
|
28
|
+
- [Related Libraries](#related-libraries)
|
|
29
|
+
- [Troubleshooting](#troubleshooting)
|
|
30
|
+
- [Support](#support)
|
|
29
31
|
- [Contributing](#contributing)
|
|
30
32
|
- [License](#license)
|
|
31
33
|
|
|
32
|
-
##
|
|
34
|
+
## Why Use This Library?
|
|
33
35
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
36
|
+
- **Lightweight** - Minimal bundle size
|
|
37
|
+
- **Reactive** - Built with Angular Signals
|
|
38
|
+
- **Performant** - Uses IntersectionObserver API
|
|
39
|
+
- **Flexible** - Works with any layout
|
|
40
|
+
- **Type-Safe** - Full TypeScript support
|
|
41
|
+
- **Zero Dependencies** - No bloat
|
|
42
|
+
- **Well Tested** - Comprehensive test coverage
|
|
43
|
+
- **Well Documented** - Clear examples and API docs
|
|
42
44
|
|
|
43
45
|
## Features
|
|
44
46
|
|
|
@@ -62,10 +64,10 @@ npm install @su-labs/scroll-spy
|
|
|
62
64
|
This library requires the following peer dependencies:
|
|
63
65
|
|
|
64
66
|
```sh
|
|
65
|
-
npm install @angular/common@^
|
|
67
|
+
npm install @angular/common@^22 @angular/core@^22
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
##
|
|
70
|
+
## Quick Start
|
|
69
71
|
|
|
70
72
|
```typescript
|
|
71
73
|
// 1. Install
|
|
@@ -154,7 +156,7 @@ export class ScrollExampleComponent {
|
|
|
154
156
|
}
|
|
155
157
|
```
|
|
156
158
|
|
|
157
|
-
##
|
|
159
|
+
## API Reference
|
|
158
160
|
|
|
159
161
|
### Service (ScrollSpyService)
|
|
160
162
|
|
|
@@ -162,7 +164,7 @@ export class ScrollExampleComponent {
|
|
|
162
164
|
|
|
163
165
|
| Signal | Type | Description |
|
|
164
166
|
|--------|------|-------------|
|
|
165
|
-
| `activeSection()` | `string
|
|
167
|
+
| `activeSection()` | `string` | ID of currently active section (`''` until a section becomes active) |
|
|
166
168
|
|
|
167
169
|
#### Methods
|
|
168
170
|
|
|
@@ -191,17 +193,17 @@ export class ScrollExampleComponent {
|
|
|
191
193
|
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.
|
|
192
194
|
|
|
193
195
|
**Key Benefits:**
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
196
|
+
- **Performance**: No scroll event listeners needed
|
|
197
|
+
- **Accuracy**: Precise intersection detection
|
|
198
|
+
- **Efficiency**: Browser-native implementation
|
|
199
|
+
- **Battery Friendly**: Optimized for mobile devices
|
|
198
200
|
|
|
199
|
-
##
|
|
201
|
+
## Browser Compatibility
|
|
200
202
|
|
|
201
203
|
Works in all modern browsers that support:
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
204
|
+
- IntersectionObserver API
|
|
205
|
+
- Angular 22+
|
|
206
|
+
- ES2022+
|
|
205
207
|
|
|
206
208
|
| Browser | Version |
|
|
207
209
|
|---------|---------|
|
|
@@ -210,16 +212,16 @@ Works in all modern browsers that support:
|
|
|
210
212
|
| Safari | ≥ 12.1 |
|
|
211
213
|
| Edge | ≥ 16 |
|
|
212
214
|
|
|
213
|
-
##
|
|
215
|
+
## Related Libraries
|
|
214
216
|
|
|
215
217
|
Part of the **@su-labs** suite:
|
|
216
218
|
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
-
|
|
220
|
-
-
|
|
219
|
+
- [@su-labs/visit-tracker](https://www.npmjs.com/package/@su-labs/visit-tracker) - User visit tracking
|
|
220
|
+
- [@su-labs/theme](https://www.npmjs.com/package/@su-labs/theme) - Theme management with dark mode support
|
|
221
|
+
- [@su-labs/notifications](https://www.npmjs.com/package/@su-labs/notifications) - Toast notification system
|
|
222
|
+
- [@su-labs/font-size](https://www.npmjs.com/package/@su-labs/font-size) - Accessible font size controls
|
|
221
223
|
|
|
222
|
-
##
|
|
224
|
+
## Troubleshooting
|
|
223
225
|
|
|
224
226
|
### Active section not updating?
|
|
225
227
|
|
|
@@ -235,13 +237,13 @@ Make sure you've imported `ScrollSpyDirective` in your component's imports array
|
|
|
235
237
|
|
|
236
238
|
### TypeScript errors?
|
|
237
239
|
|
|
238
|
-
Ensure you have Angular
|
|
240
|
+
Ensure you have Angular 22+ and TypeScript 6.0+ installed.
|
|
239
241
|
|
|
240
|
-
##
|
|
242
|
+
## Support
|
|
241
243
|
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
244
|
+
- Found a bug? [Open an issue](https://github.com/Greezaaa/settings-utils-lib/issues)
|
|
245
|
+
- Have a feature request? [Start a discussion](https://github.com/Greezaaa/settings-utils-lib/discussions)
|
|
246
|
+
- Like this library? [Give it a star!](https://github.com/Greezaaa/settings-utils-lib)
|
|
245
247
|
|
|
246
248
|
## Contributing
|
|
247
249
|
|
|
@@ -1,84 +1,83 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Directive, ElementRef, Injectable, Input, inject, signal } from "@angular/core";
|
|
3
|
+
import { observeSuScrollSpySection } from "@su-labs/core/scroll-spy";
|
|
4
|
+
var ScrollSpyService = class ScrollSpyService {
|
|
5
|
+
activeSection = signal("", ...ngDevMode ? [{ debugName: "activeSection" }] : /* istanbul ignore next */ []);
|
|
6
|
+
setActiveSection(id) {
|
|
7
|
+
this.activeSection.set(id);
|
|
8
|
+
}
|
|
9
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
10
|
+
minVersion: "12.0.0",
|
|
11
|
+
version: "22.2.4",
|
|
12
|
+
ngImport: i0,
|
|
13
|
+
type: ScrollSpyService,
|
|
14
|
+
deps: [],
|
|
15
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
16
|
+
});
|
|
17
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
18
|
+
minVersion: "12.0.0",
|
|
19
|
+
version: "22.2.4",
|
|
20
|
+
ngImport: i0,
|
|
21
|
+
type: ScrollSpyService,
|
|
22
|
+
providedIn: "root"
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
26
|
+
minVersion: "12.0.0",
|
|
27
|
+
version: "22.2.4",
|
|
28
|
+
ngImport: i0,
|
|
29
|
+
type: ScrollSpyService,
|
|
30
|
+
decorators: [{
|
|
31
|
+
type: Injectable,
|
|
32
|
+
args: [{ providedIn: "root" }]
|
|
33
|
+
}]
|
|
34
|
+
});
|
|
35
|
+
var ScrollSpyDirective = class ScrollSpyDirective {
|
|
36
|
+
sectionId;
|
|
37
|
+
el = inject(ElementRef);
|
|
38
|
+
scrollSpy = inject(ScrollSpyService);
|
|
39
|
+
stopObserving;
|
|
40
|
+
ngOnInit() {
|
|
41
|
+
this.stopObserving = observeSuScrollSpySection(this.el.nativeElement, () => this.scrollSpy.setActiveSection(this.sectionId));
|
|
42
|
+
}
|
|
43
|
+
ngOnDestroy() {
|
|
44
|
+
this.stopObserving?.();
|
|
45
|
+
}
|
|
46
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
47
|
+
minVersion: "12.0.0",
|
|
48
|
+
version: "22.2.4",
|
|
49
|
+
ngImport: i0,
|
|
50
|
+
type: ScrollSpyDirective,
|
|
51
|
+
deps: [],
|
|
52
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
53
|
+
});
|
|
54
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
55
|
+
minVersion: "14.0.0",
|
|
56
|
+
version: "22.2.4",
|
|
57
|
+
type: ScrollSpyDirective,
|
|
58
|
+
isStandalone: true,
|
|
59
|
+
selector: "[appScrollSpy]",
|
|
60
|
+
inputs: { sectionId: ["appScrollSpy", "sectionId"] },
|
|
61
|
+
ngImport: i0
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
65
|
+
minVersion: "12.0.0",
|
|
66
|
+
version: "22.2.4",
|
|
67
|
+
ngImport: i0,
|
|
68
|
+
type: ScrollSpyDirective,
|
|
69
|
+
decorators: [{
|
|
70
|
+
type: Directive,
|
|
71
|
+
args: [{
|
|
72
|
+
selector: "[appScrollSpy]",
|
|
73
|
+
standalone: true
|
|
74
|
+
}]
|
|
75
|
+
}],
|
|
76
|
+
propDecorators: { sectionId: [{
|
|
77
|
+
type: Input,
|
|
78
|
+
args: ["appScrollSpy"]
|
|
79
|
+
}] }
|
|
80
|
+
});
|
|
83
81
|
export { ScrollSpyDirective, ScrollSpyService };
|
|
84
|
-
|
|
82
|
+
|
|
83
|
+
//# 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"
|
|
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 * Sections are tracked by `ScrollSpyDirective`, which uses the framework-agnostic\n * observer from `@su-labs/core/scroll-spy`.\n */\n@Injectable({ providedIn: 'root' })\nexport class ScrollSpyService {\n /** ID of the currently visible section ('' until a section becomes active) */\n activeSection = signal<string>('');\n\n /**\n * Set the active section manually, for example when a navigation link is clicked.\n * @param id ID of the section.\n */\n setActiveSection(id: string): void {\n this.activeSection.set(id);\n }\n}\n","import { Directive, ElementRef, inject, Input, OnDestroy, OnInit } from '@angular/core';\nimport { observeSuScrollSpySection } from '@su-labs/core/scroll-spy';\nimport { SuUnsubscribe } from '@su-labs/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 reaches the vertical center of 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, OnDestroy {\n /** ID of the observed section */\n @Input('appScrollSpy') sectionId!: string;\n\n private readonly el = inject<ElementRef<Element>>(ElementRef);\n private readonly scrollSpy = inject(ScrollSpyService);\n\n /** Stops observing the section */\n private stopObserving?: SuUnsubscribe;\n\n ngOnInit(): void {\n this.stopObserving = observeSuScrollSpySection(this.el.nativeElement, () =>\n this.scrollSpy.setActiveSection(this.sectionId),\n );\n }\n\n ngOnDestroy(): void {\n this.stopObserving?.();\n }\n}\n"],"mappings":";;;AAUA,IAAa,mBAAb,MAAa,iBAAgB;CAE3B,gBAAgB,OAAe,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,gBAAA,CAAA,+BAAA,CAAA,CAAA;CAMlC,iBAAiB,IAAU;EACzB,KAAK,cAAc,IAAI,EAAE;CAC3B;CAVW,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;;;ACOlC,IAAa,qBAAb,MAAa,mBAAkB;CAEN;CAEN,KAAK,OAA4B,UAAU;CAC3C,YAAY,OAAO,gBAAgB;CAG5C;CAER,WAAQ;EACN,KAAK,gBAAgB,0BAA0B,KAAK,GAAG,qBACrD,KAAK,UAAU,iBAAiB,KAAK,SAAS,CAAC;CAEnD;CAEA,cAAW;EACT,KAAK,gBAAe;CACtB;CAlBW,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": "
|
|
3
|
+
"version": "22.1.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,10 +29,11 @@
|
|
|
29
29
|
"url": "https://github.com/Greezaaa/settings-utils-lib/issues"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@angular/common": "^
|
|
33
|
-
"@angular/core": "^
|
|
32
|
+
"@angular/common": "^22.0.0",
|
|
33
|
+
"@angular/core": "^22.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@su-labs/core": "^1.0.0",
|
|
36
37
|
"tslib": "^2.3.0"
|
|
37
38
|
},
|
|
38
39
|
"sideEffects": false,
|
|
@@ -47,5 +48,6 @@
|
|
|
47
48
|
"types": "./types/su-labs-scroll-spy.d.ts",
|
|
48
49
|
"default": "./fesm2022/su-labs-scroll-spy.mjs"
|
|
49
50
|
}
|
|
50
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"type": "module"
|
|
51
53
|
}
|
|
@@ -1,32 +1,44 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { OnInit } from
|
|
3
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { OnDestroy, 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.
|
|
6
|
+
*
|
|
7
|
+
* Sections are tracked by `ScrollSpyDirective`, which uses the framework-agnostic
|
|
8
|
+
* observer from `@su-labs/core/scroll-spy`.
|
|
7
9
|
*/
|
|
8
|
-
declare class ScrollSpyService {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export declare class ScrollSpyService {
|
|
11
|
+
/** ID of the currently visible section ('' until a section becomes active) */
|
|
12
|
+
activeSection: import("@angular/core").WritableSignal<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Set the active section manually, for example when a navigation link is clicked.
|
|
15
|
+
* @param id ID of the section.
|
|
16
|
+
*/
|
|
17
|
+
setActiveSection(id: string): void;
|
|
18
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyService, never>;
|
|
19
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
13
20
|
}
|
|
14
|
-
|
|
15
21
|
/**
|
|
16
22
|
* Directive that observes an element's visibility on the screen
|
|
17
|
-
* and updates ScrollSpyService.activeSection when it
|
|
23
|
+
* and updates ScrollSpyService.activeSection when it reaches the vertical center of the viewport.
|
|
18
24
|
*
|
|
19
25
|
* Usage:
|
|
20
26
|
* <section [appScrollSpy]="'home'">...</section>
|
|
21
27
|
*/
|
|
22
|
-
declare class ScrollSpyDirective implements OnInit {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
export declare class ScrollSpyDirective implements OnInit, OnDestroy {
|
|
29
|
+
/** ID of the observed section */
|
|
30
|
+
sectionId: string;
|
|
31
|
+
private readonly el;
|
|
32
|
+
private readonly scrollSpy;
|
|
33
|
+
/** Stops observing the section */
|
|
34
|
+
private stopObserving?;
|
|
35
|
+
ngOnInit(): void;
|
|
36
|
+
ngOnDestroy(): void;
|
|
37
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyDirective, never>;
|
|
38
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScrollSpyDirective, "[appScrollSpy]", never, {
|
|
39
|
+
"sectionId": {
|
|
40
|
+
"alias": "appScrollSpy";
|
|
41
|
+
"required": false;
|
|
42
|
+
};
|
|
43
|
+
}, {}, never, never, true, never>;
|
|
44
|
+
}
|