@rdlabo/ngx-cdk-scroll-strategies 22.0.0-1 → 22.0.0-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 CHANGED
@@ -1,10 +1,25 @@
1
1
  # @rdlabo/ngx-cdk-scroll-strategies
2
2
 
3
+ > Angular CDK virtual scroll with variable and dynamic item heights.
4
+
3
5
  ## Overview
4
6
 
5
- This is strategies of dynamic item size for `@angular/cdk/scrolling`. This allows you set specify each item size in the array to be used for Virtual Scroll. Although the repository name includes “Ionic” this strategy only works with Angular.
7
+ `@rdlabo/ngx-cdk-scroll-strategies` is an Angular CDK virtual scroll strategy for lists with variable item heights. It lets you supply the exact pixel size of every item instead of requiring one fixed `[itemSize]` for the whole list.
8
+
9
+ Use `[itemDynamicSizes]` with known or measured item heights. Unlike the experimental `[autosize]` strategy, this library does not estimate unmeasured items from an average size. It works with `@angular/cdk/scrolling` and does not depend on Ionic.
10
+
11
+ ## When to use this strategy
12
+
13
+ Use this library when:
14
+
15
+ - list items or rows have different heights;
16
+ - dynamic item heights can be calculated from data or measured from rendered components;
17
+ - `scrollToIndex` and scroll positions must use exact variable-height geometry; or
18
+ - a chat UI needs reverse virtual scrolling.
19
+
20
+ If an item height is not known in advance, measure it and pass the result as shown in [Advanced Usage](./docs/advanced.md). This is not a drop-in strategy that discovers every unknown DOM height automatically.
6
21
 
7
- This is a simple coding concept:
22
+ The basic Angular CDK variable-height virtual scroll setup is:
8
23
 
9
24
  ```html
10
25
  <cdk-virtual-scroll-viewport
@@ -16,11 +31,11 @@ This is a simple coding concept:
16
31
  </cdk-virtual-scroll-viewport>
17
32
  ```
18
33
 
19
- Use `[itemDynamicSizes]` directive instead of `[itemSize]` or `[autosize]` directive. `[itemDynamicSizes]` value's type is `itemDynamicSize[]`.
34
+ Use the `[itemDynamicSizes]` directive instead of `[itemSize]` or `[autosize]`. Its value has the type `itemDynamicSize[]`.
20
35
 
21
36
  Every data item must have one corresponding `itemDynamicSizes` entry in the same order. Each `itemSize` must be a finite number greater than zero. If Angular updates the data and size signals in separate turns, the strategy keeps the last complete geometry until their lengths match; it never estimates unknown heights.
22
37
 
23
- This library is based largely on this blog: https://dev.to/georgii/virtual-scrolling-of-content-with-variable-height-with-angular-3a52
38
+ This library is based largely on [Virtual scrolling of content with variable height with Angular](https://dev.to/georgii/virtual-scrolling-of-content-with-variable-height-with-angular-3a52).
24
39
 
25
40
  ## Features
26
41
 
package/docs/advanced.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Call this after [Installation](../README.md#installation).
2
2
 
3
- > This is a practical demo. Make scroll items separate components and get a height for each component.
3
+ > This Angular CDK dynamic item height example measures every scroll item as a separate component.
4
4
  > It is difficult without basic knowledge of Angular.
5
5
 
6
6
  - Demo: https://rdlabo-ionic-angular-library.netlify.app/main/scroll-strategies/advanced
package/docs/faq.md CHANGED
@@ -1,7 +1,15 @@
1
- ### Why don't use `autosize` directive?
1
+ ### Does Angular CDK virtual scroll support variable or dynamic item heights?
2
2
 
3
- `autosize` directive use average item size. This is not support "item size is changed" "item is removed". Because don't have item size cache.
3
+ The standard `[itemSize]` strategy assumes that every item has the same fixed size. Use this library's `[itemDynamicSizes]` directive to provide a different known or measured height for each item.
4
+
5
+ ### How is this different from the `autosize` strategy?
6
+
7
+ Angular CDK Experimental's `autosize` strategy measures rendered items and estimates unmeasured items from the average item size. `[itemDynamicSizes]` calculates scroll ranges and offsets from the per-item sizes supplied by your application.
4
8
 
5
9
  https://github.com/angular/components/blob/main/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts#L49C3-L59
6
10
 
7
- Dynamic size can be specified for more flexible application design.
11
+ When each item height is known or can be measured after rendering, this avoids average-size estimation and keeps the virtual scroll geometry exact.
12
+
13
+ ### Does this set a dynamic height on `cdk-virtual-scroll-viewport` itself?
14
+
15
+ No. This library handles variable heights for the items inside the viewport. Setting the viewport container's own height or `max-height` based on its content is a separate problem.
package/docs/reverse.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Call this after [Installation](../README.md#installation).
2
2
 
3
- > This is a demo for reverse scrolling like WeChat.
3
+ > This demo combines variable item heights with reverse virtual scrolling for a chat UI like WeChat.
4
4
 
5
5
  - Demo: https://rdlabo-ionic-angular-library.netlify.app/main/scroll-strategies/reverse
6
6
  - Source: https://github.com/rdlabo-dev/ionic-angular-library/tree/v21.6.2/projects/demo/src/app/scroll-strategies/pages/scroll-reverse
package/docs/simple.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Call this after [Installation](../README.md#installation).
2
2
 
3
- > This is a simple example of how to use it.
3
+ > This basic Angular CDK virtual scroll example is for items whose variable heights are already known.
4
4
 
5
5
  - Demo: https://rdlabo-ionic-angular-library.netlify.app/main/scroll-strategies/simple
6
6
  - Source: https://github.com/rdlabo-dev/ionic-angular-library/tree/v21.6.2/projects/demo/src/app/scroll-strategies/pages/scroll-simple
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rdlabo/ngx-cdk-scroll-strategies",
3
- "version": "22.0.0-1",
3
+ "version": "22.0.0-3",
4
+ "description": "Angular CDK virtual scroll strategy for variable and dynamic item heights.",
4
5
  "repository": {
5
6
  "type": "git",
6
7
  "url": "git@github.com:rdlabo-dev/ionic-angular-library.git"