angular-infinity-scrolling 2.1.1 → 2.2.1
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/README.md +103 -30
- package/fesm2022/angular-infinity-scrolling.mjs +58 -0
- package/fesm2022/angular-infinity-scrolling.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/angular-infinity-scroller.directive.d.ts +14 -0
- package/package.json +39 -16
- package/public-api.d.ts +1 -0
- package/ng-package.json +0 -7
- package/src/lib/angular-infinity-scroller.directive.spec.ts +0 -8
- package/src/lib/angular-infinity-scroller.directive.ts +0 -46
- package/src/public-api.ts +0 -5
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
package/README.md
CHANGED
|
@@ -1,47 +1,120 @@
|
|
|
1
|
-
|
|
1
|
+
# Angular Infinite Scroller
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> Note: Current version of package is compatible with angular version above 17
|
|
3
|
+
A **lightweight, high‑performance infinite scrolling directive for Angular applications**, designed to work smoothly with modern Angular versions and SSR setups.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
Go to the ts file of component e.g. example.component.ts and add AngularInfinityScrollerDirective inside imports.
|
|
5
|
+
---
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
## ✨ Features
|
|
8
|
+
|
|
9
|
+
- 🚀 Simple directive‑based API
|
|
10
|
+
- ⚡ High‑performance scroll detection
|
|
11
|
+
- 🧩 Works with standalone components
|
|
12
|
+
- 🌐 Compatible with Angular 17+
|
|
13
|
+
- 📦 Zero external dependencies
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 📦 Installation
|
|
18
|
+
|
|
19
|
+
Install the package using npm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install angular-infinity-scroller
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🚀 Getting Started
|
|
28
|
+
|
|
29
|
+
Import `AngularInfinityScrollerDirective` into your component and add it to `imports`.
|
|
30
|
+
|
|
31
|
+
### Example Component
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { Component } from '@angular/core';
|
|
35
|
+
import { AngularInfinityScrollerDirective } from 'angular-infinity-scroller';
|
|
11
36
|
|
|
12
37
|
@Component({
|
|
13
38
|
selector: 'app-example',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
styleUrl: './exaple.component.scss',
|
|
39
|
+
standalone: true,
|
|
40
|
+
imports: [AngularInfinityScrollerDirective],
|
|
41
|
+
templateUrl: './example.component.html',
|
|
42
|
+
styleUrl: './example.component.scss',
|
|
19
43
|
})
|
|
20
|
-
export class ExampleComponent{
|
|
44
|
+
export class ExampleComponent {
|
|
45
|
+
handleScroll() {
|
|
46
|
+
// load more data here
|
|
47
|
+
}
|
|
48
|
+
}
|
|
21
49
|
```
|
|
22
50
|
|
|
23
|
-
|
|
24
|
-
followed by consuming the directive in example.component.
|
|
25
|
-
```
|
|
51
|
+
---
|
|
26
52
|
|
|
27
|
-
|
|
53
|
+
## 🧪 Usage
|
|
28
54
|
|
|
55
|
+
Apply the directive to a scrollable container.
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<div
|
|
59
|
+
class="scrollable-parent"
|
|
60
|
+
angularInfinityScroller
|
|
61
|
+
[scrollDistance]="2"
|
|
62
|
+
(onScrolled)="handleScroll()"
|
|
63
|
+
>
|
|
64
|
+
</div>
|
|
29
65
|
```
|
|
30
|
-
scrollDistance - input which accpet a number between 1 and 9.
|
|
31
|
-
Describing to emit the data if scrollable height is less than or equal to (number*10) percent.
|
|
32
|
-
[scrollDistance]='2' value will be emitted if scrollable height is less than or 20%.
|
|
33
|
-
NOTE: if invalid scrollDistance is given, then default value of 2 will be used for calculation;
|
|
34
66
|
|
|
35
|
-
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ⚙️ Directive API
|
|
70
|
+
|
|
71
|
+
### `scrollDistance` (Input)
|
|
72
|
+
|
|
73
|
+
- **Type:** `number`
|
|
74
|
+
- **Range:** `1 – 9`
|
|
75
|
+
- **Default:** `2`
|
|
76
|
+
|
|
77
|
+
Defines when the scroll event should trigger.
|
|
78
|
+
|
|
79
|
+
Example:
|
|
80
|
+
- `[scrollDistance]="2"` → emits when remaining scroll height is **≤ 20%**
|
|
81
|
+
|
|
82
|
+
If an invalid value is provided, the directive automatically falls back to the default value.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### `onScrolled` (Output)
|
|
87
|
+
|
|
88
|
+
- **Type:** `() => void`
|
|
89
|
+
|
|
90
|
+
Emits when the scroll threshold is reached.
|
|
91
|
+
|
|
92
|
+
```html
|
|
36
93
|
(onScrolled)="handleScroll()"
|
|
37
94
|
```
|
|
38
95
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 🔧 Compatibility
|
|
99
|
+
|
|
100
|
+
- ✅ Angular **17 and above**
|
|
101
|
+
- ✅ Standalone components
|
|
102
|
+
- ✅ SSR‑friendly
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🤝 Contributing
|
|
107
|
+
|
|
108
|
+
Suggestions, improvements, and pull requests are welcome.
|
|
109
|
+
|
|
110
|
+
If you encounter any issues, please raise them on GitHub:
|
|
111
|
+
👉 https://github.com/Jayant061/angular-infinity-scroller/issues
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## ⭐ Support
|
|
116
|
+
|
|
117
|
+
If this package helps you, please consider starring the repository ⭐
|
|
118
|
+
|
|
119
|
+
Happy coding! 🚀
|
|
43
120
|
|
|
44
|
-
```
|
|
45
|
-
Any suggestions or contributions are most welcome. If you are facing any issue with the packge please raise the issue in the github, I'll happt to resolve the bugs.
|
|
46
|
-
Happy coding!!
|
|
47
|
-
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, computed, output, inject, ElementRef, signal, Directive } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class AngularInfinityScrollerDirective {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.onScroll = this.onScroll.bind(this);
|
|
7
|
+
}
|
|
8
|
+
scrollDistance = input(2);
|
|
9
|
+
scrollDistanceCoefficient = computed(() => {
|
|
10
|
+
const val = this.scrollDistance();
|
|
11
|
+
if (val > 9) {
|
|
12
|
+
return 2;
|
|
13
|
+
}
|
|
14
|
+
return val;
|
|
15
|
+
});
|
|
16
|
+
onScrolled = output();
|
|
17
|
+
el = inject(ElementRef);
|
|
18
|
+
prevScrollHeight = signal(0);
|
|
19
|
+
ngAfterViewInit() {
|
|
20
|
+
this.el.nativeElement.addEventListener('scroll', this.onScroll);
|
|
21
|
+
}
|
|
22
|
+
onScroll() {
|
|
23
|
+
const height = Math.floor(this.el?.nativeElement.scrollHeight - this.el.nativeElement.clientHeight);
|
|
24
|
+
const scrollValue = Math.floor(this.el?.nativeElement.scrollTop);
|
|
25
|
+
const unexploredContentHeight = height - this.prevScrollHeight();
|
|
26
|
+
if (unexploredContentHeight < 0) { // if the list item quantity reduced (applying filter)
|
|
27
|
+
this.prevScrollHeight.set(0);
|
|
28
|
+
}
|
|
29
|
+
const emitTriggerHeight = this.prevScrollHeight() + Math.ceil((1 - ((this.scrollDistanceCoefficient()) / 10)) * unexploredContentHeight);
|
|
30
|
+
if (scrollValue >= (emitTriggerHeight) && this.prevScrollHeight() !== height) {
|
|
31
|
+
this.onScrolled.emit();
|
|
32
|
+
this.prevScrollHeight.set(height);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
ngOnDestroy() {
|
|
36
|
+
this.el.nativeElement.removeEventListener('scroll', this.onScroll);
|
|
37
|
+
}
|
|
38
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AngularInfinityScrollerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
39
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.1", type: AngularInfinityScrollerDirective, isStandalone: true, selector: "[angularInfinityScroller]", inputs: { scrollDistance: { classPropertyName: "scrollDistance", publicName: "scrollDistance", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onScrolled: "onScrolled" }, ngImport: i0 });
|
|
40
|
+
}
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AngularInfinityScrollerDirective, decorators: [{
|
|
42
|
+
type: Directive,
|
|
43
|
+
args: [{
|
|
44
|
+
selector: '[angularInfinityScroller]',
|
|
45
|
+
standalone: true
|
|
46
|
+
}]
|
|
47
|
+
}], ctorParameters: () => [] });
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Public API Surface of angular-infinity-scroller
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generated bundle index. Do not edit.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
export { AngularInfinityScrollerDirective };
|
|
58
|
+
//# sourceMappingURL=angular-infinity-scrolling.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-infinity-scrolling.mjs","sources":["../../../projects/angular-infinity-scroller/src/lib/angular-infinity-scroller.directive.ts","../../../projects/angular-infinity-scroller/src/public-api.ts","../../../projects/angular-infinity-scroller/src/angular-infinity-scrolling.ts"],"sourcesContent":["import { computed, Directive, ElementRef, inject, input, output, signal } from '@angular/core';\n\n@Directive({\n selector: '[angularInfinityScroller]',\n standalone: true\n})\nexport class AngularInfinityScrollerDirective {\n\n constructor() {\n this.onScroll = this.onScroll.bind(this);\n }\n public scrollDistance = input<number>(2);\n private readonly scrollDistanceCoefficient = computed(() => {\n const val = this.scrollDistance();\n if (val > 9) {\n return 2\n }\n return val;\n })\n public onScrolled = output();\n private el: ElementRef<HTMLDivElement> = inject(ElementRef);\n private prevScrollHeight = signal<number>(0);\n\n\n ngAfterViewInit(): void {\n this.el.nativeElement.addEventListener('scroll', this.onScroll);\n }\n\n private onScroll(): void {\n const height = Math.floor(this.el?.nativeElement.scrollHeight - this.el.nativeElement.clientHeight);\n const scrollValue = Math.floor(this.el?.nativeElement.scrollTop);\n const unexploredContentHeight = height - this.prevScrollHeight();\n if (unexploredContentHeight < 0) {// if the list item quantity reduced (applying filter)\n this.prevScrollHeight.set(0);\n }\n const emitTriggerHeight = this.prevScrollHeight() + Math.ceil((1 - ((this.scrollDistanceCoefficient()) / 10)) * unexploredContentHeight);\n if (scrollValue >= (emitTriggerHeight) && this.prevScrollHeight() !== height) {\n this.onScrolled.emit();\n this.prevScrollHeight.set(height);\n }\n }\n ngOnDestroy(): void {\n this.el.nativeElement.removeEventListener('scroll', this.onScroll);\n }\n\n}\n","/*\n * Public API Surface of angular-infinity-scroller\n */\n\nexport * from './lib/angular-infinity-scroller.directive'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAMa,gCAAgC,CAAA;AAE3C,IAAA,WAAA,GAAA;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;;AAEnC,IAAA,cAAc,GAAG,KAAK,CAAS,CAAC,CAAC;AACvB,IAAA,yBAAyB,GAAG,QAAQ,CAAC,MAAK;AACzD,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,EAAE;AACjC,QAAA,IAAI,GAAG,GAAG,CAAC,EAAE;AACX,YAAA,OAAO,CAAC;;AAEV,QAAA,OAAO,GAAG;AACZ,KAAC,CAAC;IACK,UAAU,GAAG,MAAM,EAAE;AACpB,IAAA,EAAE,GAA+B,MAAM,CAAC,UAAU,CAAC;AACnD,IAAA,gBAAgB,GAAG,MAAM,CAAS,CAAC,CAAC;IAG5C,eAAe,GAAA;AACb,QAAA,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;;IAGzD,QAAQ,GAAA;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC;AACnG,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,SAAS,CAAC;QAChE,MAAM,uBAAuB,GAAG,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE;AAChE,QAAA,IAAI,uBAAuB,GAAG,CAAC,EAAE;AAC/B,YAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;;AAE9B,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,EAAE,CAAC,IAAI,uBAAuB,CAAC;AACxI,QAAA,IAAI,WAAW,KAAK,iBAAiB,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,KAAK,MAAM,EAAE;AAC5E,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;AACtB,YAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC;;;IAGrC,WAAW,GAAA;AACT,QAAA,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;;uGApCzD,gCAAgC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAhC,gCAAgC,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,2BAAA,EAAA,MAAA,EAAA,EAAA,cAAA,EAAA,EAAA,iBAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,UAAA,EAAA,YAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAhC,gCAAgC,EAAA,UAAA,EAAA,CAAA;kBAJ5C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,2BAA2B;AACrC,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACLD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export declare class AngularInfinityScrollerDirective {
|
|
3
|
+
constructor();
|
|
4
|
+
scrollDistance: import("@angular/core").InputSignal<number>;
|
|
5
|
+
private readonly scrollDistanceCoefficient;
|
|
6
|
+
onScrolled: import("@angular/core").OutputEmitterRef<void>;
|
|
7
|
+
private el;
|
|
8
|
+
private prevScrollHeight;
|
|
9
|
+
ngAfterViewInit(): void;
|
|
10
|
+
private onScroll;
|
|
11
|
+
ngOnDestroy(): void;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AngularInfinityScrollerDirective, never>;
|
|
13
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AngularInfinityScrollerDirective, "[angularInfinityScroller]", never, { "scrollDistance": { "alias": "scrollDistance"; "required": false; "isSignal": true; }; }, { "onScrolled": "onScrolled"; }, never, never, true, never>;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-infinity-scrolling",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
|
+
"description": "High-performance infinite scrolling directive for Angular applications with SSR support.",
|
|
5
|
+
"homepage": "https://github.com/Jayant061/angular-infinity-scroller",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
|
-
"url": "https://github.com/Jayant061/angular-infinity-scroller"
|
|
8
|
+
"url": "git+https://github.com/Jayant061/angular-infinity-scroller.git"
|
|
7
9
|
},
|
|
8
10
|
"bugs": {
|
|
9
11
|
"url": "https://github.com/Jayant061/angular-infinity-scroller/issues"
|
|
10
12
|
},
|
|
11
13
|
"keywords": [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"infinite",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
14
|
+
"angular",
|
|
15
|
+
"angular-library",
|
|
16
|
+
"angular-directive",
|
|
17
|
+
"angular-ssr",
|
|
18
|
+
"infinite-scroll",
|
|
19
|
+
"infinite-scrolling",
|
|
20
|
+
"infinite-scroller",
|
|
21
|
+
"scroll",
|
|
22
|
+
"scrolling",
|
|
23
|
+
"virtual-scroll",
|
|
24
|
+
"pagination",
|
|
25
|
+
"lazy-loading",
|
|
26
|
+
"ngx-infinite-scroll",
|
|
27
|
+
"angular-infinite-scroll"
|
|
22
28
|
],
|
|
23
|
-
"author":
|
|
29
|
+
"author": {
|
|
30
|
+
"name": "Jayant Thakur",
|
|
31
|
+
"url": "https://github.com/Jayant061"
|
|
32
|
+
},
|
|
24
33
|
"license": "ISC",
|
|
34
|
+
"sideEffects": false,
|
|
25
35
|
"peerDependencies": {
|
|
26
|
-
"@angular/
|
|
27
|
-
"@angular/
|
|
36
|
+
"@angular/core": ">=16.0.0 <21.0.0",
|
|
37
|
+
"@angular/common": ">=16.0.0 <21.0.0"
|
|
28
38
|
},
|
|
29
39
|
"dependencies": {
|
|
30
40
|
"tslib": "^2.3.0"
|
|
31
41
|
},
|
|
32
|
-
"
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"module": "fesm2022/angular-infinity-scrolling.mjs",
|
|
46
|
+
"typings": "index.d.ts",
|
|
47
|
+
"exports": {
|
|
48
|
+
"./package.json": {
|
|
49
|
+
"default": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
".": {
|
|
52
|
+
"types": "./index.d.ts",
|
|
53
|
+
"default": "./fesm2022/angular-infinity-scrolling.mjs"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
33
56
|
}
|
package/public-api.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/angular-infinity-scroller.directive';
|
package/ng-package.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AngularInfinityScrollerDirective } from './angular-infinity-scroller.directive';
|
|
2
|
-
|
|
3
|
-
describe('AngularInfinityScrollerDirective', () => {
|
|
4
|
-
it('should create an instance', () => {
|
|
5
|
-
const directive = new AngularInfinityScrollerDirective();
|
|
6
|
-
expect(directive).toBeTruthy();
|
|
7
|
-
});
|
|
8
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { computed, Directive, ElementRef, inject, input, output, signal } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Directive({
|
|
4
|
-
selector: '[angularInfinityScroller]',
|
|
5
|
-
standalone: true
|
|
6
|
-
})
|
|
7
|
-
export class AngularInfinityScrollerDirective {
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
this.onScroll = this.onScroll.bind(this);
|
|
11
|
-
}
|
|
12
|
-
public scrollDistance = input<number>(2);
|
|
13
|
-
private readonly scrollDistanceCoefficient = computed(() => {
|
|
14
|
-
const val = this.scrollDistance();
|
|
15
|
-
if (val > 9) {
|
|
16
|
-
return 2
|
|
17
|
-
}
|
|
18
|
-
return val;
|
|
19
|
-
})
|
|
20
|
-
public onScrolled = output();
|
|
21
|
-
private el: ElementRef<HTMLDivElement> = inject(ElementRef);
|
|
22
|
-
private prevScrollHeight = signal<number>(0);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ngAfterViewInit(): void {
|
|
26
|
-
this.el.nativeElement.addEventListener('scroll', this.onScroll);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private onScroll(): void {
|
|
30
|
-
const height = Math.floor(this.el?.nativeElement.scrollHeight - this.el.nativeElement.clientHeight);
|
|
31
|
-
const scrollValue = Math.floor(this.el?.nativeElement.scrollTop);
|
|
32
|
-
const unexploredContentHeight = height - this.prevScrollHeight();
|
|
33
|
-
if (unexploredContentHeight < 0) {// if the list item quantity reduced (applying filter)
|
|
34
|
-
this.prevScrollHeight.set(0);
|
|
35
|
-
}
|
|
36
|
-
const emitTriggerHeight = this.prevScrollHeight() + Math.ceil((1 - ((this.scrollDistanceCoefficient()) / 10)) * unexploredContentHeight);
|
|
37
|
-
if (scrollValue >= (emitTriggerHeight) && this.prevScrollHeight() !== height) {
|
|
38
|
-
this.onScrolled.emit();
|
|
39
|
-
this.prevScrollHeight.set(height);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
ngOnDestroy(): void {
|
|
43
|
-
this.el.nativeElement.removeEventListener('scroll', this.onScroll);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}
|
package/src/public-api.ts
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "../../tsconfig.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"outDir": "../../out-tsc/lib",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"inlineSources": true,
|
|
10
|
-
"types": []
|
|
11
|
-
},
|
|
12
|
-
"exclude": [
|
|
13
|
-
"**/*.spec.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "./tsconfig.lib.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"declarationMap": false
|
|
7
|
-
},
|
|
8
|
-
"angularCompilerOptions": {
|
|
9
|
-
"compilationMode": "partial"
|
|
10
|
-
}
|
|
11
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "../../tsconfig.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"outDir": "../../out-tsc/spec",
|
|
7
|
-
"types": [
|
|
8
|
-
"jasmine"
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
|
-
"include": [
|
|
12
|
-
"**/*.spec.ts",
|
|
13
|
-
"**/*.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|