angular-infinity-scrolling 1.5.1 → 1.5.3
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 +17 -8
- package/ng-package.json +7 -0
- package/package.json +31 -42
- package/src/lib/angular-infinity-scroller.directive.spec.ts +8 -0
- package/src/lib/angular-infinity-scroller.directive.ts +39 -0
- package/src/public-api.ts +5 -0
- package/tsconfig.lib.json +15 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/angular-infinity-scrolling.mjs +0 -53
- package/fesm2022/angular-infinity-scrolling.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/angular-infinity-scroller.directive.d.ts +0 -14
- package/public-api.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
## Thank you for using angular -infinity-scroller for infinite scrolling.
|
|
2
|
-
|
|
3
|
-
>
|
|
2
|
+
|
|
3
|
+
> [!TIP]
|
|
4
|
+
> Note: Current version of package is compatible with angular version above 17
|
|
4
5
|
|
|
5
6
|
go to the directory, open terminal and and install package using `npm i angular-infinity-scroller`
|
|
6
7
|
Go to the ts file of component e.g. example.component.ts and add AngularInfinityScrollerDirective inside imports.
|
|
7
8
|
|
|
8
|
-
|
|
9
9
|
```ruby
|
|
10
10
|
import {AngularInfinityScrollerDirective} from "angular-infinity-scroller";
|
|
11
11
|
|
|
@@ -19,19 +19,28 @@ import {AngularInfinityScrollerDirective} from "angular-infinity-scroller";
|
|
|
19
19
|
})
|
|
20
20
|
export class ExampleComponent{}
|
|
21
21
|
```
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
```
|
|
23
24
|
followed by consuming the directive in example.component.
|
|
24
|
-
|
|
25
|
+
```
|
|
26
|
+
|
|
25
27
|
### Currently Directive has 2 properties
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
```
|
|
27
30
|
scrollDistance - input which accpet a number between 1 and 10.
|
|
28
31
|
Describing to emit the data if scrollable height is less than or equal to (number*10) percent.
|
|
29
32
|
[scrollDistance]='2' value will be emitted if scrollable height is less than or 20%.
|
|
30
33
|
|
|
31
34
|
onScrolled - output that accept a voidFunction to be invoked on emit
|
|
32
35
|
(onScrolled)="handleScroll()"
|
|
33
|
-
|
|
36
|
+
```
|
|
37
|
+
|
|
34
38
|
```ruby
|
|
35
39
|
<div class='scrollable-parent' angularInfinityScroller [scrollDistance]="4" (onScrolled)="handleScroll()">
|
|
36
40
|
</div>
|
|
37
|
-
```
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
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.
|
|
45
|
+
Happy coding!!
|
|
46
|
+
```
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,42 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "angular-infinity-scrolling",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"repository": {
|
|
5
|
-
"type": "git",
|
|
6
|
-
"url": "https://github.com/Jayant061/angular-infinity-scroller"
|
|
7
|
-
},
|
|
8
|
-
"bugs": {
|
|
9
|
-
"url": "https://github.com/Jayant061/angular-infinity-scroller/issues"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [
|
|
12
|
-
"Angular-infinity-scrolling",
|
|
13
|
-
"Angular-infinity-scroller",
|
|
14
|
-
"infinity-scroller",
|
|
15
|
-
"Angular-infinite-scroller",
|
|
16
|
-
"Angular-infinite-scroll",
|
|
17
|
-
"infinte-scroll",
|
|
18
|
-
"infinite",
|
|
19
|
-
"Angular"
|
|
20
|
-
],
|
|
21
|
-
"author": "Jayant Thakur",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"@angular/common": "^19.0.0",
|
|
25
|
-
"@angular/core": "^19.0.0"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"tslib": "^2.3.0"
|
|
29
|
-
},
|
|
30
|
-
"sideEffects": false
|
|
31
|
-
|
|
32
|
-
"typings": "index.d.ts",
|
|
33
|
-
"exports": {
|
|
34
|
-
"./package.json": {
|
|
35
|
-
"default": "./package.json"
|
|
36
|
-
},
|
|
37
|
-
".": {
|
|
38
|
-
"types": "./index.d.ts",
|
|
39
|
-
"default": "./fesm2022/angular-infinity-scrolling.mjs"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "angular-infinity-scrolling",
|
|
3
|
+
"version": "1.5.3",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/Jayant061/angular-infinity-scroller"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/Jayant061/angular-infinity-scroller/issues"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Angular-infinity-scrolling",
|
|
13
|
+
"Angular-infinity-scroller",
|
|
14
|
+
"infinity-scroller",
|
|
15
|
+
"Angular-infinite-scroller",
|
|
16
|
+
"Angular-infinite-scroll",
|
|
17
|
+
"infinte-scroll",
|
|
18
|
+
"infinite",
|
|
19
|
+
"Angular"
|
|
20
|
+
],
|
|
21
|
+
"author": "Jayant Thakur",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@angular/common": "^19.0.0",
|
|
25
|
+
"@angular/core": "^19.0.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"tslib": "^2.3.0"
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": false
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Directive, ElementRef, inject, input, output } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[angularInfinityScroller]',
|
|
5
|
+
standalone: true
|
|
6
|
+
})
|
|
7
|
+
export class AngularInfinityScrollerDirective {
|
|
8
|
+
|
|
9
|
+
constructor() { }
|
|
10
|
+
public scrollDistance = input<number>();
|
|
11
|
+
public onScrolled = output();
|
|
12
|
+
private el:ElementRef<HTMLDivElement> = inject(ElementRef);
|
|
13
|
+
private prevScrollHeight:number = 0;
|
|
14
|
+
ngAfterViewInit(): void {
|
|
15
|
+
this.el.nativeElement.addEventListener('scroll',this.onScroll.bind(this));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
ngOnDestroy(): void {
|
|
19
|
+
this.el.nativeElement.removeEventListener('scroll',this.onScroll.bind(this));
|
|
20
|
+
}
|
|
21
|
+
private isEmit:boolean = true;
|
|
22
|
+
private onScroll():void{
|
|
23
|
+
const height = Math.floor(this.el?.nativeElement.scrollHeight - this.el.nativeElement.clientHeight);
|
|
24
|
+
const scrollValue = Math.floor(this.el?.nativeElement.scrollTop);
|
|
25
|
+
const emitTriggerHeight = Math.ceil((1-((this.scrollDistance()??2)/10))*height);
|
|
26
|
+
if(scrollValue>= (emitTriggerHeight) && !this.isEmit){
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
else if(scrollValue < (emitTriggerHeight)){
|
|
30
|
+
this.isEmit = true;
|
|
31
|
+
}
|
|
32
|
+
if(scrollValue>= (emitTriggerHeight) && this.prevScrollHeight !== height){
|
|
33
|
+
this.onScrolled.emit();
|
|
34
|
+
this.prevScrollHeight = height;
|
|
35
|
+
this.isEmit = false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, output, inject, ElementRef, Directive } from '@angular/core';
|
|
3
|
-
|
|
4
|
-
class AngularInfinityScrollerDirective {
|
|
5
|
-
constructor() { }
|
|
6
|
-
scrollDistance = input();
|
|
7
|
-
onScrolled = output();
|
|
8
|
-
el = inject(ElementRef);
|
|
9
|
-
prevScrollHeight = 0;
|
|
10
|
-
ngAfterViewInit() {
|
|
11
|
-
this.el.nativeElement.addEventListener('scroll', this.onScroll.bind(this));
|
|
12
|
-
}
|
|
13
|
-
ngOnDestroy() {
|
|
14
|
-
this.el.nativeElement.removeEventListener('scroll', this.onScroll.bind(this));
|
|
15
|
-
}
|
|
16
|
-
isEmit = true;
|
|
17
|
-
onScroll() {
|
|
18
|
-
const height = Math.floor(this.el?.nativeElement.scrollHeight - this.el.nativeElement.clientHeight);
|
|
19
|
-
const scrollValue = Math.floor(this.el?.nativeElement.scrollTop);
|
|
20
|
-
const emitTriggerHeight = Math.ceil((1 - ((this.scrollDistance() ?? 2) / 10)) * height);
|
|
21
|
-
if (scrollValue >= (emitTriggerHeight) && !this.isEmit) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
else if (scrollValue < (emitTriggerHeight)) {
|
|
25
|
-
this.isEmit = true;
|
|
26
|
-
}
|
|
27
|
-
if (scrollValue >= (emitTriggerHeight) && this.prevScrollHeight !== height) {
|
|
28
|
-
this.onScrolled.emit();
|
|
29
|
-
this.prevScrollHeight = height;
|
|
30
|
-
this.isEmit = false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AngularInfinityScrollerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
34
|
-
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 });
|
|
35
|
-
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: AngularInfinityScrollerDirective, decorators: [{
|
|
37
|
-
type: Directive,
|
|
38
|
-
args: [{
|
|
39
|
-
selector: '[angularInfinityScroller]',
|
|
40
|
-
standalone: true
|
|
41
|
-
}]
|
|
42
|
-
}], ctorParameters: () => [] });
|
|
43
|
-
|
|
44
|
-
/*
|
|
45
|
-
* Public API Surface of angular-infinity-scroller
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Generated bundle index. Do not edit.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
export { AngularInfinityScrollerDirective };
|
|
53
|
-
//# sourceMappingURL=angular-infinity-scrolling.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 { Directive, ElementRef, inject, input, output } from '@angular/core';\r\n\r\n@Directive({\r\n selector: '[angularInfinityScroller]',\r\n standalone: true\r\n})\r\nexport class AngularInfinityScrollerDirective {\r\n\r\n constructor() { }\r\n public scrollDistance = input<number>();\r\n public onScrolled = output();\r\n private el:ElementRef<HTMLDivElement> = inject(ElementRef);\r\n private prevScrollHeight:number = 0;\r\n ngAfterViewInit(): void {\r\n this.el.nativeElement.addEventListener('scroll',this.onScroll.bind(this));\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.el.nativeElement.removeEventListener('scroll',this.onScroll.bind(this));\r\n }\r\n private isEmit:boolean = true;\r\n private onScroll():void{\r\n const height = Math.floor(this.el?.nativeElement.scrollHeight - this.el.nativeElement.clientHeight);\r\n const scrollValue = Math.floor(this.el?.nativeElement.scrollTop);\r\n const emitTriggerHeight = Math.ceil((1-((this.scrollDistance()??2)/10))*height);\r\n if(scrollValue>= (emitTriggerHeight) && !this.isEmit){\r\n return;\r\n }\r\n else if(scrollValue < (emitTriggerHeight)){\r\n this.isEmit = true;\r\n }\r\n if(scrollValue>= (emitTriggerHeight) && this.prevScrollHeight !== height){\r\n this.onScrolled.emit();\r\n this.prevScrollHeight = height;\r\n this.isEmit = false;\r\n }\r\n }\r\n\r\n}\r\n","/*\r\n * Public API Surface of angular-infinity-scroller\r\n */\r\n\r\nexport * from './lib/angular-infinity-scroller.directive'\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAMa,gCAAgC,CAAA;AAE3C,IAAA,WAAA,GAAA;IACO,cAAc,GAAG,KAAK,EAAU;IAChC,UAAU,GAAG,MAAM,EAAE;AACpB,IAAA,EAAE,GAA8B,MAAM,CAAC,UAAU,CAAC;IAClD,gBAAgB,GAAU,CAAC;IACnC,eAAe,GAAA;AACb,QAAA,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;IAG3E,WAAW,GAAA;AACT,QAAA,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,mBAAmB,CAAC,QAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;IAEtE,MAAM,GAAW,IAAI;IACrB,QAAQ,GAAA;QACZ,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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
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class AngularInfinityScrollerDirective {
|
|
3
|
-
constructor();
|
|
4
|
-
scrollDistance: import("@angular/core").InputSignal<number | undefined>;
|
|
5
|
-
onScrolled: import("@angular/core").OutputEmitterRef<void>;
|
|
6
|
-
private el;
|
|
7
|
-
private prevScrollHeight;
|
|
8
|
-
ngAfterViewInit(): void;
|
|
9
|
-
ngOnDestroy(): void;
|
|
10
|
-
private isEmit;
|
|
11
|
-
private onScroll;
|
|
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/public-api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/angular-infinity-scroller.directive';
|