angular-infinity-scrolling 2.1.1 → 2.2.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/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 +14 -3
- 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
|
@@ -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,I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BAAiB,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-infinity-scrolling",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/Jayant061/angular-infinity-scroller"
|
|
@@ -29,5 +29,16 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"tslib": "^2.3.0"
|
|
31
31
|
},
|
|
32
|
-
"sideEffects": false
|
|
33
|
-
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"module": "fesm2022/angular-infinity-scrolling.mjs",
|
|
34
|
+
"typings": "index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
"./package.json": {
|
|
37
|
+
"default": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./index.d.ts",
|
|
41
|
+
"default": "./fesm2022/angular-infinity-scrolling.mjs"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
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
|
-
}
|