Skip to content

Commit cbfacdd

Browse files
committed
address comments
1 parent 12be786 commit cbfacdd

File tree

3 files changed

+34
-41
lines changed

3 files changed

+34
-41
lines changed

src/cdk-experimental/scrolling/virtual-scroll-viewport.scss

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
// When elements such as `<tr>` or `<li>` are repeated inside the cdk-virtual-scroll-viewport,
2+
// their container element (e.g. `<table>`, `<ul>`, etc.) needs to be placed in the viewport as
3+
// well. We reset some properties here to prevent these container elements from introducing
4+
// additional space that would throw off the the scrolling calculations.
5+
@mixin _cdk-virtual-scroll-clear-container-space($direction) {
6+
$start: if($direction == horizontal, 'left', 'top');
7+
$end: if($direction == horizontal, 'right', 'bottom');
8+
9+
& > dl:not([cdkVirtualFor]),
10+
& > ol:not([cdkVirtualFor]),
11+
& > table:not([cdkVirtualFor]),
12+
& > ul:not([cdkVirtualFor]) {
13+
padding: {
14+
#{$start}: 0;
15+
#{$end}: 0
16+
};
17+
margin: {
18+
#{$start}: 0;
19+
#{$end}: 0
20+
};
21+
border: {
22+
#{$start}-width: 0;
23+
#{$end}-width: 0
24+
};
25+
outline: none;
26+
}
27+
}
28+
29+
130
// Scrolling container.
231
cdk-virtual-scroll-viewport {
332
display: block;
@@ -16,48 +45,12 @@ cdk-virtual-scroll-viewport {
1645

1746
.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper {
1847
bottom: 0;
19-
20-
& > dl,
21-
& > ol,
22-
& > table,
23-
& > ul {
24-
padding: {
25-
left: 0;
26-
right: 0
27-
};
28-
margin: {
29-
left: 0;
30-
right: 0
31-
};
32-
border: {
33-
left-width: 0;
34-
right-width: 0
35-
};
36-
outline: none;
37-
}
48+
@include _cdk-virtual-scroll-clear-container-space(horizontal);
3849
}
3950

4051
.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper {
4152
right: 0;
42-
43-
& > dl,
44-
& > ol,
45-
& > table,
46-
& > ul {
47-
padding: {
48-
top: 0;
49-
bottom: 0
50-
};
51-
margin: {
52-
top: 0;
53-
bottom: 0
54-
};
55-
border: {
56-
top-width: 0;
57-
bottom-width: 0
58-
};
59-
outline: none;
60-
}
53+
@include _cdk-virtual-scroll-clear-container-space(vertical);
6154
}
6255

6356
// Spacer element that whose width or height will be adjusted to match the size of the entire data

src/cdk-experimental/scrolling/virtual-scroll-viewport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy {
6868
_totalContentSize = 0;
6969

7070
/**
71-
* The the rendered content transform, used to move the rendered portion of the content to the
72-
* correct place in the viewport.
71+
* The CSS transform applied to the rendered subset of items so that they appear within the bounds
72+
* of the visible viewport.
7373
*/
7474
private _renderedContentTransform: string;
7575

src/cdk-experimental/scrolling/virtual-scroll.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ content.
147147
Some HTML elements such as `<tr>` and `<li>` have limitations on the kinds of parent elements they
148148
can be placed inside. To enable virtual scrolling over these type of elements, place the elements in
149149
their proper parent, and then wrap the whole thing in a `cdk-virtual-scroll-viewport`. Be careful
150-
that the parent does not introduce additional space (e.g. via `margin` or `padding`) as it may
150+
that the parent does not introduce additional space (e.g. via `margin` or `padding`) as it will
151151
interfere with the scrolling.
152152

153153
```html

0 commit comments

Comments
 (0)