@ceriousdevtech/ngx-cerious-scroll 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +261 -13
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,24 +1,272 @@
1
- # NgxCeriousScroll
1
+ # @ceriousdevtech/ngx-cerious-scroll
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.0.
3
+ Angular wrapper for [@ceriousdevtech/cerious-scroll](https://www.npmjs.com/package/@ceriousdevtech/cerious-scroll), providing high-performance virtual scrolling with variable row heights for Angular applications.
4
4
 
5
- ## Code scaffolding
5
+ ## Features
6
6
 
7
- Run `ng generate component component-name --project ngx-cerious-scroll` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-cerious-scroll`.
8
- > Note: Don't forget to add `--project ngx-cerious-scroll` or else it will be added to the default project in your `angular.json` file.
7
+ - 🚀 **High Performance** - Handles millions of items with smooth scrolling
8
+ - 📏 **Variable Heights** - Full support for dynamic and variable row heights
9
+ - 🎯 **Angular Integration** - Seamless integration with Angular templates and change detection
10
+ - 🎨 **Flexible Templates** - Use Angular templates with full data binding
11
+ - 📦 **Standalone Components** - Built with Angular standalone components
12
+ - 🔄 **Reactive** - RxJS observables for viewport change events
13
+ - ⚡ **Auto Render** - Automatic rendering on scroll or manual control
9
14
 
10
- ## Build
15
+ ## Installation
11
16
 
12
- Run `ng build ngx-cerious-scroll` to build the project. The build artifacts will be stored in the `dist/` directory.
17
+ ```bash
18
+ npm install @ceriousdevtech/ngx-cerious-scroll @ceriousdevtech/cerious-scroll
19
+ ```
13
20
 
14
- ## Publishing
21
+ ## Usage
15
22
 
16
- After building your library with `ng build ngx-cerious-scroll`, go to the dist folder `cd dist/ngx-cerious-scroll` and run `npm publish`.
23
+ ### Component API
17
24
 
18
- ## Running unit tests
25
+ The simplest way to use virtual scrolling with the `<cerious-scroll>` component:
19
26
 
20
- Run `ng test ngx-cerious-scroll` to execute the unit tests via [Karma](https://karma-runner.github.io).
27
+ ```typescript
28
+ import { Component } from '@angular/core';
29
+ import { CeriousScrollComponent } from '@ceriousdevtech/ngx-cerious-scroll';
21
30
 
22
- ## Further help
31
+ @Component({
32
+ selector: 'app-my-list',
33
+ standalone: true,
34
+ imports: [CeriousScrollComponent],
35
+ template: `
36
+ <cerious-scroll
37
+ [items]="items"
38
+ [options]="scrollOptions"
39
+ (viewportChange)="onViewportChange($event)">
40
+ <ng-template ceriousScrollItem let-item let-index="index">
41
+ <div class="row">
42
+ {{ index }}: {{ item.title }}
43
+ </div>
44
+ </ng-template>
45
+ </cerious-scroll>
46
+ `,
47
+ styles: [`
48
+ cerious-scroll {
49
+ height: 600px;
50
+ display: block;
51
+ }
52
+ .row {
53
+ padding: 16px;
54
+ border-bottom: 1px solid #eee;
55
+ }
56
+ `]
57
+ })
58
+ export class MyListComponent {
59
+ items = Array.from({ length: 10000 }, (_, i) => ({
60
+ id: i,
61
+ title: `Item ${i}`
62
+ }));
23
63
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
64
+ scrollOptions = {
65
+ wheel: { enabled: true },
66
+ touch: { enabled: true },
67
+ keyboard: { enabled: true },
68
+ };
69
+
70
+ onViewportChange(detail: any) {
71
+ console.log('Viewport changed:', detail);
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### Directive API
77
+
78
+ For more control, use the `[ceriousScroll]` directive on any element:
79
+
80
+ ```typescript
81
+ import { Component, TemplateRef, ViewChild } from '@angular/core';
82
+ import { CeriousScrollDirective } from '@ceriousdevtech/ngx-cerious-scroll';
83
+
84
+ @Component({
85
+ selector: 'app-advanced-list',
86
+ standalone: true,
87
+ imports: [CeriousScrollDirective],
88
+ template: `
89
+ <div
90
+ ceriousScroll
91
+ [ceriousScrollItems]="items"
92
+ [ceriousScrollItemTemplate]="rowTemplate"
93
+ [ceriousScrollOptions]="options"
94
+ [ceriousScrollAutoRender]="true"
95
+ (ceriousScrollViewportChange)="onViewportChange($event)"
96
+ (ceriousScrollMeasuredViewport)="onMeasured($event)"
97
+ (ceriousScrollReady)="onReady($event)"
98
+ class="viewport">
99
+ </div>
100
+
101
+ <ng-template #rowTemplate let-item let-index="index">
102
+ <div class="row" [style.height.px]="getRowHeight(index)">
103
+ <strong>#{{ index }}</strong>: {{ item.name }}
104
+ </div>
105
+ </ng-template>
106
+ `,
107
+ styles: [`
108
+ .viewport {
109
+ height: 600px;
110
+ overflow: hidden;
111
+ }
112
+ `]
113
+ })
114
+ export class AdvancedListComponent {
115
+ items = Array.from({ length: 50000 }, (_, i) => ({
116
+ id: i,
117
+ name: `Row ${i}`
118
+ }));
119
+
120
+ options = {
121
+ wheel: { enabled: true },
122
+ touch: { enabled: true },
123
+ keyboard: { enabled: true },
124
+ };
125
+
126
+ getRowHeight(index: number): number {
127
+ // Variable row heights
128
+ return 40 + (index % 5) * 10;
129
+ }
130
+
131
+ onViewportChange(detail: any) {
132
+ console.log('Scroll position:', detail);
133
+ }
134
+
135
+ onMeasured(range: any) {
136
+ console.log('Rendered range:', range);
137
+ }
138
+
139
+ onReady(scroller: any) {
140
+ console.log('Scroller ready:', scroller);
141
+ }
142
+ }
143
+ ```
144
+
145
+ ### Using with Large Datasets (getItem)
146
+
147
+ For very large datasets, use `getItem` instead of passing the entire array:
148
+
149
+ ```typescript
150
+ import { Component } from '@angular/core';
151
+ import { CeriousScrollDirective } from '@ceriousdevtech/ngx-cerious-scroll';
152
+
153
+ @Component({
154
+ selector: 'app-large-list',
155
+ standalone: true,
156
+ imports: [CeriousScrollDirective],
157
+ template: `
158
+ <div
159
+ ceriousScroll
160
+ [ceriousScrollTotalElements]="1000000"
161
+ [ceriousScrollGetItem]="getItem"
162
+ [ceriousScrollItemTemplate]="rowTpl"
163
+ [ceriousScrollOptions]="options"
164
+ class="viewport">
165
+ </div>
166
+
167
+ <ng-template #rowTpl let-item let-index="index">
168
+ <div class="row">{{ item.value }}</div>
169
+ </ng-template>
170
+ `,
171
+ styles: [`
172
+ .viewport { height: 600px; }
173
+ .row { padding: 12px; }
174
+ `]
175
+ })
176
+ export class LargeListComponent {
177
+ options = {
178
+ wheel: { enabled: true },
179
+ touch: { enabled: true },
180
+ keyboard: { enabled: true },
181
+ };
182
+
183
+ getItem = (index: number) => {
184
+ return {
185
+ value: `Dynamic item ${index}`
186
+ };
187
+ };
188
+ }
189
+ ```
190
+
191
+ ## API Reference
192
+
193
+ ### Component: `<cerious-scroll>`
194
+
195
+ #### Inputs
196
+ - `items: any[]` - Array of items to render
197
+ - `totalElements: number` - Optional explicit total count (defaults to items.length)
198
+ - `itemTemplate: TemplateRef` - Template for rendering each item
199
+ - `options: CeriousScrollOptions` - Configuration options
200
+ - `autoRender: boolean` - Auto-render on scroll (default: true)
201
+
202
+ #### Outputs
203
+ - `viewportChange: EventEmitter<CeriousViewportChangeDetail>` - Emits on scroll
204
+ - `measuredViewport: EventEmitter<MeasuredViewportRange>` - Emits after each render
205
+ - `scrollerReady: EventEmitter<CeriousScroll>` - Emits when scroller is initialized
206
+
207
+ ### Directive: `[ceriousScroll]`
208
+
209
+ #### Inputs
210
+ - `ceriousScrollItems: any[]` - Array of items
211
+ - `ceriousScrollTotalElements: number` - Total element count
212
+ - `ceriousScrollGetItem: (index: number) => any` - Function to retrieve item by index
213
+ - `ceriousScrollItemTemplate: TemplateRef` - Template for rendering
214
+ - `ceriousScrollOptions: CeriousScrollOptions` - Configuration options
215
+ - `ceriousScrollAutoRender: boolean` - Auto-render on scroll (default: true)
216
+
217
+ #### Outputs
218
+ - `ceriousScrollViewportChange: EventEmitter<CeriousViewportChangeDetail>` - Scroll events
219
+ - `ceriousScrollMeasuredViewport: EventEmitter<MeasuredViewportRange>` - Render metrics
220
+ - `ceriousScrollReady: EventEmitter<CeriousScroll>` - Scroller instance
221
+
222
+ ### Template Context
223
+
224
+ Templates receive the following context:
225
+
226
+ ```typescript
227
+ {
228
+ $implicit: TItem; // The item (default binding)
229
+ item: TItem; // The item (named binding)
230
+ index: number; // Row index
231
+ }
232
+ ```
233
+
234
+ Usage in templates:
235
+ ```html
236
+ <ng-template ceriousScrollItem let-item let-index="index">
237
+ {{ index }}: {{ item.name }}
238
+ </ng-template>
239
+ ```
240
+
241
+ ## Options
242
+
243
+ Configure scrolling behavior with `CeriousScrollOptions`:
244
+
245
+ ```typescript
246
+ const options = {
247
+ wheel: {
248
+ enabled: true,
249
+ emitViewportChangeEvent: true,
250
+ coalesceViewportChangeEvent: true
251
+ },
252
+ touch: { enabled: true },
253
+ keyboard: { enabled: true },
254
+ attachScrollbar: true,
255
+ autoResize: true,
256
+ observeContentChanges: true
257
+ };
258
+ ```
259
+
260
+ ## License
261
+
262
+ Dual-licensed under MIT OR LicenseRef-CeriousScroll-Commercial.
263
+
264
+ See [LICENSE-MIT](./LICENSE-MIT) and [LICENSE-COMMERCIAL](./LICENSE-COMMERCIAL) for details.
265
+
266
+ ## Related Packages
267
+
268
+ - [@ceriousdevtech/cerious-scroll](https://www.npmjs.com/package/@ceriousdevtech/cerious-scroll) - Core virtual scrolling engine
269
+
270
+ ## Support
271
+
272
+ For issues and feature requests, please visit the [GitHub repository](https://github.com/ceriousdevtech/ngx-cerious-scroll).
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ceriousdevtech/ngx-cerious-scroll",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "(MIT OR LicenseRef-CeriousScroll-Commercial)",
5
5
  "peerDependencies": {
6
- "@angular/common": "^17.3.0",
7
- "@angular/core": "^17.3.0",
8
- "@ceriousdevtech/cerious-scroll": "^1.0.0"
6
+ "@angular/common": ">=16.0.0",
7
+ "@angular/core": ">=16.0.0",
8
+ "@ceriousdevtech/cerious-scroll": "^1.0.1"
9
9
  },
10
10
  "dependencies": {
11
11
  "tslib": "^2.3.0"