Skip to content

Commit dcd2282

Browse files
mmalerbajelbourn
authored andcommitted
feat(virtual-scroll): move from cdk-experimental to cdk (#12438)
1 parent d392a8d commit dcd2282

32 files changed

+874
-840
lines changed

src/cdk-experimental/scrolling/BUILD.bazel

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
package(default_visibility=["//visibility:public"])
22
load("@angular//:index.bzl", "ng_module")
33
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
4-
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
54

65

76
ng_module(
87
name = "scrolling",
98
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
109
module_name = "@angular/cdk-experimental/scrolling",
11-
assets = [":virtual-scroll-viewport.css"] + glob(["**/*.html"]),
1210
deps = [
1311
"//src/cdk/coercion",
1412
"//src/cdk/collections",
15-
"//src/cdk/platform",
13+
"//src/cdk/scrolling",
1614
"@rxjs",
1715
],
1816
tsconfig = "//src/cdk-experimental:tsconfig-build.json",
1917
)
2018

21-
sass_binary(
22-
name = "virtual_scroll_viewport_scss",
23-
src = "virtual-scroll-viewport.scss",
24-
)
25-
26-
2719
ts_library(
2820
name = "scrolling_test_sources",
2921
testonly = 1,
3022
srcs = glob(["**/*.spec.ts"]),
3123
deps = [
3224
":scrolling",
33-
"//src/cdk/collections",
25+
"//src/cdk/scrolling",
3426
"//src/cdk/testing",
3527
"@rxjs",
3628
],
@@ -42,8 +34,6 @@ ts_web_test(
4234
bootstrap = [
4335
"//:web_test_bootstrap_scripts",
4436
],
45-
tags = ["manual"],
46-
4737
# Do not sort
4838
deps = [
4939
"//:tslib_bundle",

src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
import {coerceNumberProperty} from '@angular/cdk/coercion';
1010
import {ListRange} from '@angular/cdk/collections';
11+
import {
12+
CdkVirtualScrollViewport,
13+
VIRTUAL_SCROLL_STRATEGY,
14+
VirtualScrollStrategy
15+
} from '@angular/cdk/scrolling';
1116
import {Directive, forwardRef, Input, OnChanges} from '@angular/core';
1217
import {Observable} from 'rxjs';
13-
import {VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy} from './virtual-scroll-strategy';
14-
import {CdkVirtualScrollViewport} from './virtual-scroll-viewport';
1518

1619

1720
/**

src/cdk-experimental/scrolling/public-api.ts

-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@
77
*/
88

99
export * from './auto-size-virtual-scroll';
10-
export * from './fixed-size-virtual-scroll';
1110
export * from './scrolling-module';
12-
export * from './virtual-for-of';
13-
export * from './virtual-scroll-strategy';
14-
export * from './virtual-scroll-viewport';

src/cdk-experimental/scrolling/scrolling-module.ts

+2-15
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,10 @@
88

99
import {NgModule} from '@angular/core';
1010
import {CdkAutoSizeVirtualScroll} from './auto-size-virtual-scroll';
11-
import {CdkFixedSizeVirtualScroll} from './fixed-size-virtual-scroll';
12-
import {CdkVirtualForOf} from './virtual-for-of';
13-
import {CdkVirtualScrollViewport} from './virtual-scroll-viewport';
1411

1512

1613
@NgModule({
17-
exports: [
18-
CdkAutoSizeVirtualScroll,
19-
CdkFixedSizeVirtualScroll,
20-
CdkVirtualForOf,
21-
CdkVirtualScrollViewport,
22-
],
23-
declarations: [
24-
CdkAutoSizeVirtualScroll,
25-
CdkFixedSizeVirtualScroll,
26-
CdkVirtualForOf,
27-
CdkVirtualScrollViewport,
28-
],
14+
exports: [CdkAutoSizeVirtualScroll],
15+
declarations: [CdkAutoSizeVirtualScroll],
2916
})
3017
export class ScrollingModule {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
**Warning: this component is still experimental. It may have bugs and the API may change at any
2+
time**
3+
4+
### Scrolling over items with different sizes
5+
When the items have different or unknown sizes, you can use the `AutoSizeVirtualScrollStrategy`.
6+
This can be added to your viewport by using the `autosize` directive.
7+
8+
```html
9+
<cdk-virtual-scroll-viewport autosize>
10+
...
11+
</cdk-virtual-scroll-viewport>
12+
```
13+
14+
The `autosize` strategy is configured through two inputs: `minBufferPx` and `addBufferPx`.
15+
16+
**`minBufferPx`** determines the minimum space outside virtual scrolling viewport that will be
17+
filled with content. Increasing this will increase the amount of content a user will see before more
18+
content must be rendered. However, too large a value will cause more content to be rendered than is
19+
necessary.
20+
21+
**`addBufferPx`** determines the amount of content that will be added incrementally as the viewport
22+
is scrolled. This should be greater than the size of `minBufferPx` so that one "render" is needed at
23+
a time.
24+
25+
```html
26+
<cdk-virtual-scroll-viewport autosize minBufferPx="50" addBufferPx="100">
27+
...
28+
</cdk-virtual-scroll-viewport>
29+
```
30+
31+
Because the auto size strategy needs to measure the size of the elements, its performance may not
32+
be as good as the fixed size strategy.

src/cdk-experimental/scrolling/tsconfig-build.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"extends": "../tsconfig-build",
33
"files": [
4-
"public-api.ts",
5-
"./typings.d.ts"
4+
"public-api.ts"
65
],
76
"angularCompilerOptions": {
87
"annotateForClosureCompiler": true,

0 commit comments

Comments
 (0)