@su-labs/scroll-spy 1.0.2 → 21.0.4
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
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [21.0.4] - 2026-02-03
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **BREAKING:** Updated to Angular 21 support. This version requires Angular 21.0.0 or higher.
|
|
12
|
+
- Updated peer dependencies to `@angular/common: ^21.0.0` and `@angular/core: ^21.0.0`.
|
|
13
|
+
- Aligned package version with Angular major version for clearer compatibility (v21.x.x = Angular 21 support).
|
|
14
|
+
|
|
15
|
+
### Notes
|
|
16
|
+
- Projects using Angular 20 or below should continue using version 1.0.3.
|
|
17
|
+
- This release maintains full backward compatibility with the 1.x API - only the Angular version requirement has changed.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## [1.0.2] - 2025-08-30
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Ensured `"license": "MIT"` is correctly reflected in the published package metadata.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [1.0.1] - 2025-08-30
|
|
27
|
+
|
|
28
|
+
### Note
|
|
29
|
+
- This version was published with incorrect package content and is deprecated. Please use `1.0.4`.
|
|
30
|
+
|
|
31
|
+
## [1.0.0] - 2024-08-26
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Initial public release of the @su-labs/scroll-spy library.
|
|
36
|
+
|
|
37
|
+
- Introduction of ScrollSpyService, a reactive service that uses an Angular Signal to track the currently visible section.
|
|
38
|
+
|
|
39
|
+
- Introduction of ScrollSpyDirective, a standalone directive that uses the browser's native IntersectionObserver to automatically update the ScrollSpyService when a section enters the viewport.
|
|
40
|
+
|
|
41
|
+
- Configurable rootMargin to allow precise control over when the scroll-spy effect is triggered.
|
|
42
|
+
|
|
43
|
+
- Full support for modern Angular applications using @for, @if, and inject().
|
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ import { signal, Injectable, inject, ElementRef, Input, Directive } from '@angul
|
|
|
8
8
|
class ScrollSpyService {
|
|
9
9
|
/** ID of the currently visible section */
|
|
10
10
|
activeSection = signal('', ...(ngDevMode ? [{ debugName: "activeSection" }] : []));
|
|
11
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
12
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
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
13
|
}
|
|
14
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyService, decorators: [{
|
|
15
15
|
type: Injectable,
|
|
16
16
|
args: [{ providedIn: 'root' }]
|
|
17
17
|
}] });
|
|
@@ -58,10 +58,10 @@ class ScrollSpyDirective {
|
|
|
58
58
|
});
|
|
59
59
|
observer.observe(this.el.nativeElement);
|
|
60
60
|
}
|
|
61
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
62
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
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
63
|
}
|
|
64
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ScrollSpyDirective, decorators: [{
|
|
65
65
|
type: Directive,
|
|
66
66
|
args: [{
|
|
67
67
|
selector: '[appScrollSpy]',
|
|
@@ -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
|
|
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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-labs/scroll-spy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.4",
|
|
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": "^
|
|
33
|
-
"@angular/core": "^
|
|
32
|
+
"@angular/common": "^21.0.0",
|
|
33
|
+
"@angular/core": "^21.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"tslib": "^2.3.0"
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"module": "fesm2022/su-labs-scroll-spy.mjs",
|
|
41
|
-
"typings": "
|
|
41
|
+
"typings": "types/su-labs-scroll-spy.d.ts",
|
|
42
42
|
"exports": {
|
|
43
43
|
"./package.json": {
|
|
44
44
|
"default": "./package.json"
|
|
45
45
|
},
|
|
46
46
|
".": {
|
|
47
|
-
"types": "./
|
|
47
|
+
"types": "./types/su-labs-scroll-spy.d.ts",
|
|
48
48
|
"default": "./fesm2022/su-labs-scroll-spy.mjs"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
File without changes
|