@annalib/anna-core 7.2.4 → 7.2.5
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/annalib-anna-core.d.ts +5 -0
- package/esm2020/annalib-anna-core.mjs +5 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.mjs +35 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.mjs +22 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.mjs +21 -0
- package/esm2020/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.mjs +15 -0
- package/esm2020/lib/anna-core-shared-lib/constants/shared.constant.mjs +35 -0
- package/esm2020/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.mjs +282 -0
- package/esm2020/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.mjs +27 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-generic-data-type.model.mjs +2 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.mjs +2 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-manage-users.model.mjs +8 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.mjs +2 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-sort.model.mjs +7 -0
- package/esm2020/lib/anna-core-shared-lib/models/anna-tooltip.model.mjs +30 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.mjs +26 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.mjs +46 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.mjs +25 -0
- package/esm2020/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.mjs +16 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-date-time-format.service.mjs +199 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-filter.service.mjs +469 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-generic-table.service.mjs +124 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-global-config.service.mjs +133 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-number-format.service.mjs +41 -0
- package/esm2020/lib/anna-core-shared-lib/services/anna-sort.service.mjs +147 -0
- package/esm2020/lib/anna-core.module.mjs +180 -0
- package/esm2020/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.mjs +101 -0
- package/esm2020/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.mjs +364 -0
- package/esm2020/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.mjs +1834 -0
- package/esm2020/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.mjs +69 -0
- package/esm2020/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.mjs +357 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.mjs +189 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.mjs +2 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.mjs +178 -0
- package/esm2020/lib/anna-generic-table-lib/directives/anna-virtual-table/index.mjs +2 -0
- package/esm2020/public-api.mjs +50 -0
- package/fesm2015/annalib-anna-core.mjs +4875 -0
- package/fesm2015/annalib-anna-core.mjs.map +1 -0
- package/fesm2020/annalib-anna-core.mjs +4868 -0
- package/fesm2020/annalib-anna-core.mjs.map +1 -0
- package/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.d.ts +16 -0
- package/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.d.ts +11 -0
- package/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.d.ts +11 -0
- package/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.d.ts +8 -0
- package/lib/anna-core-shared-lib/constants/shared.constant.d.ts +33 -0
- package/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.d.ts +34 -0
- package/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.d.ts +9 -0
- package/lib/anna-core-shared-lib/models/anna-generic-data-type.model.d.ts +16 -0
- package/{src/lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.ts → lib/anna-core-shared-lib/models/anna-global-dropdown-config.model.d.ts} +9 -21
- package/lib/anna-core-shared-lib/models/anna-manage-users.model.d.ts +6 -0
- package/{src/lib/anna-core-shared-lib/models/anna-non-editable-gt-models.ts → lib/anna-core-shared-lib/models/anna-non-editable-gt-models.d.ts} +17 -28
- package/lib/anna-core-shared-lib/models/anna-sort.model.d.ts +11 -0
- package/lib/anna-core-shared-lib/models/anna-tooltip.model.d.ts +25 -0
- package/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.d.ts +9 -0
- package/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.d.ts +9 -0
- package/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.d.ts +9 -0
- package/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.d.ts +7 -0
- package/lib/anna-core-shared-lib/services/anna-date-time-format.service.d.ts +27 -0
- package/lib/anna-core-shared-lib/services/anna-filter.service.d.ts +74 -0
- package/lib/anna-core-shared-lib/services/anna-generic-table.service.d.ts +28 -0
- package/lib/anna-core-shared-lib/services/anna-global-config.service.d.ts +21 -0
- package/lib/anna-core-shared-lib/services/anna-number-format.service.d.ts +7 -0
- package/lib/anna-core-shared-lib/services/anna-sort.service.d.ts +16 -0
- package/lib/anna-core.module.d.ts +36 -0
- package/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.d.ts +34 -0
- package/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.d.ts +70 -0
- package/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.d.ts +283 -0
- package/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.d.ts +17 -0
- package/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.d.ts +141 -0
- package/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.d.ts +89 -0
- package/{src/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.ts → lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/index.d.ts} +0 -0
- package/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.d.ts +45 -0
- package/{src/lib/anna-generic-table-lib/directives/anna-virtual-table/index.ts → lib/anna-generic-table-lib/directives/anna-virtual-table/index.d.ts} +0 -0
- package/package.json +39 -19
- package/{src/public-api.ts → public-api.d.ts} +0 -28
- package/.browserslistrc +0 -16
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -14
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.html +0 -22
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-buyer-approval-icon-template/anna-buyer-approval-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.html +0 -33
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-icon-column/anna-icon-column.component.ts +0 -28
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.html +0 -20
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-live-icon-template/anna-live-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.html +0 -3
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.scss +0 -17
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.spec.ts +0 -24
- package/src/lib/anna-core-shared-lib/components/anna-no-data/anna-no-data.component.ts +0 -20
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.html +0 -23
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-notify-icon-template/anna-notify-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.html +0 -15
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-pay-for-performance-icon-template/anna-pay-for-performance-icon-template.component.ts +0 -19
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.html +0 -14
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.scss +0 -0
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.spec.ts +0 -25
- package/src/lib/anna-core-shared-lib/components/anna-rejected-icon-template/anna-rejected-icon-template.component.ts +0 -16
- package/src/lib/anna-core-shared-lib/constants/shared.constant.ts +0 -35
- package/src/lib/anna-core-shared-lib/directives/digits-only/digits-only.directive.ts +0 -307
- package/src/lib/anna-core-shared-lib/directives/show-ellipsis-text/show-ellipsis-text.directive.ts +0 -19
- package/src/lib/anna-core-shared-lib/models/anna-generic-data-type.model.ts +0 -19
- package/src/lib/anna-core-shared-lib/models/anna-manage-users.model.ts +0 -6
- package/src/lib/anna-core-shared-lib/models/anna-sort.model.ts +0 -13
- package/src/lib/anna-core-shared-lib/models/anna-tooltip.model.ts +0 -44
- package/src/lib/anna-core-shared-lib/pipes/annaConvertZeroOrNullOrUndefined.pipe.ts +0 -20
- package/src/lib/anna-core-shared-lib/pipes/annaFilterSearchedText.pipe.ts +0 -43
- package/src/lib/anna-core-shared-lib/pipes/annaReplaceChar.pipe.ts +0 -19
- package/src/lib/anna-core-shared-lib/pipes/annaTypeOfData.pipe.ts +0 -12
- package/src/lib/anna-core-shared-lib/services/anna-date-time-format.service.ts +0 -219
- package/src/lib/anna-core-shared-lib/services/anna-filter.service.ts +0 -563
- package/src/lib/anna-core-shared-lib/services/anna-generic-table.service.ts +0 -136
- package/src/lib/anna-core-shared-lib/services/anna-global-config.service.ts +0 -170
- package/src/lib/anna-core-shared-lib/services/anna-number-format.service.ts +0 -43
- package/src/lib/anna-core-shared-lib/services/anna-sort.service.ts +0 -179
- package/src/lib/anna-core.module.ts +0 -112
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.html +0 -46
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.scss +0 -153
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.spec.ts +0 -24
- package/src/lib/anna-dropdown-lib/components/anna-calendar-filter/anna-calendar-filter.component.ts +0 -106
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.html +0 -129
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.scss +0 -275
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.spec.ts +0 -24
- package/src/lib/anna-dropdown-lib/components/anna-week-calendar-filter/anna-week-calendar-filter.component.ts +0 -414
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.html +0 -1080
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.scss +0 -668
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.spec.ts +0 -25
- package/src/lib/anna-generic-table-lib/components/anna-non-editable-generic-table/anna-non-editable-generic-table.component.ts +0 -2186
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.html +0 -10
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.scss +0 -1
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.spec.ts +0 -24
- package/src/lib/anna-generic-table-lib/components/anna-sort/anna-sort.component.ts +0 -69
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.html +0 -13
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.scss +0 -88
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.spec.ts +0 -25
- package/src/lib/anna-generic-table-lib/components/anna-table-virtual-scroll-viewport/anna-table-virtual-scroll-viewport.component.ts +0 -460
- package/src/lib/anna-generic-table-lib/directives/anna-fixed-row-size-table-virtual-scroll-strategy/anna-fixed-row-size-table-virtual-scroll-strategy.directive.ts +0 -237
- package/src/lib/anna-generic-table-lib/directives/anna-virtual-table/anna-virtual-table.directive.ts +0 -204
- package/src/test.ts +0 -27
- package/tsconfig.lib.json +0 -19
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "sort";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
|
|
2
|
-
|
|
3
|
-
import { SortComponent } from "./anna-sort.component";
|
|
4
|
-
|
|
5
|
-
describe("SortComponent", () => {
|
|
6
|
-
let component: SortComponent;
|
|
7
|
-
let fixture: ComponentFixture<SortComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(waitForAsync(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [SortComponent],
|
|
12
|
-
}).compileComponents();
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
fixture = TestBed.createComponent(SortComponent);
|
|
17
|
-
component = fixture.componentInstance;
|
|
18
|
-
fixture.detectChanges();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should create", () => {
|
|
22
|
-
expect(component).toBeTruthy();
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Angular import statements
|
|
2
|
-
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
|
3
|
-
import { SortOption, SortType, SortTypeEnum } from '../../../anna-core-shared-lib/models/anna-sort.model';
|
|
4
|
-
import { AnnaSortService } from '../../../anna-core-shared-lib/services/anna-sort.service';
|
|
5
|
-
|
|
6
|
-
//Add onChange push change detection
|
|
7
|
-
@Component({
|
|
8
|
-
selector: 'anna-core-sort-lib',
|
|
9
|
-
templateUrl: './anna-sort.component.html',
|
|
10
|
-
styleUrls: ['./anna-sort.component.scss'],
|
|
11
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
12
|
-
})
|
|
13
|
-
export class AnnaSortComponent implements OnChanges{
|
|
14
|
-
|
|
15
|
-
@Input() sortObjectKey: string;
|
|
16
|
-
@Output() sortOptionClicked = new EventEmitter<SortType>();
|
|
17
|
-
|
|
18
|
-
sortOptions: SortOption[] = [
|
|
19
|
-
{
|
|
20
|
-
sortType: SortTypeEnum.ASC,
|
|
21
|
-
isOptionActive: false,
|
|
22
|
-
text: 'A to Z',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
sortType: SortTypeEnum.DESC,
|
|
26
|
-
isOptionActive: false,
|
|
27
|
-
text: 'Z to A',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
sortType: SortTypeEnum.DEFAULT,
|
|
31
|
-
isOptionActive: false,
|
|
32
|
-
text: 'Default',
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
constructor(private annaSortService: AnnaSortService) {}
|
|
37
|
-
|
|
38
|
-
ngOnChanges(changes: SimpleChanges): void {
|
|
39
|
-
console.log("sort component ngOnChanges");
|
|
40
|
-
console.log(this.sortObjectKey);
|
|
41
|
-
if(changes["sortObjectKey"] && changes["sortObjectKey"].currentValue){
|
|
42
|
-
console.log("inside sort active func");
|
|
43
|
-
let sortType = this.annaSortService.columnSortState.get(this.sortObjectKey);
|
|
44
|
-
this.setSortType(sortType);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
sortOptionChanged(index: number, sortType: SortType) {
|
|
50
|
-
this.sortOptions.forEach((item) => (item.isOptionActive = false));
|
|
51
|
-
this.sortOptions[index].isOptionActive = true;
|
|
52
|
-
this.sortOptionClicked.emit(sortType);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
ngOnInit(): void {
|
|
56
|
-
console.log("sort component ngOnInit");
|
|
57
|
-
console.log(this.annaSortService.columnSortState);
|
|
58
|
-
this.annaSortService.updateSortTypeSubject.subscribe((item: string) => {
|
|
59
|
-
this.setSortType(item);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
setSortType(option: string){
|
|
64
|
-
option = option ? option :SortTypeEnum.DEFAULT;
|
|
65
|
-
this.sortOptions.forEach(item => item.isOptionActive = false);
|
|
66
|
-
let index = this.sortOptions.findIndex(item => item.sortType == option);
|
|
67
|
-
this.sortOptions[index].isOptionActive = true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Wrap the rendered content in an element that will be used to offset it based on the scroll
|
|
3
|
-
position.
|
|
4
|
-
-->
|
|
5
|
-
<div #contentWrapper class="anna-table-virtual-scroll-content-wrapper">
|
|
6
|
-
<ng-content></ng-content>
|
|
7
|
-
</div>
|
|
8
|
-
<!--
|
|
9
|
-
Spacer used to force the scrolling container to the correct size for the *total* number of items
|
|
10
|
-
so that the scrollbar captures the size of the entire data set.
|
|
11
|
-
-->
|
|
12
|
-
<div class="app-table-virtual-scroll-spacer" [style.width]="_totalContentWidth" [style.height]="_totalContentHeight">
|
|
13
|
-
</div>
|
|
@@ -1,88 +0,0 @@
|
|
|
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 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
|
-
// Scrolling container.
|
|
30
|
-
anna-table-virtual-scroll-viewport {
|
|
31
|
-
display: block;
|
|
32
|
-
position: relative;
|
|
33
|
-
overflow: auto;
|
|
34
|
-
contain: strict;
|
|
35
|
-
// transform: translateZ(0);
|
|
36
|
-
will-change: scroll-position;
|
|
37
|
-
-webkit-overflow-scrolling: touch;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Wrapper element for the rendered content. This element will be transformed to push the rendered
|
|
42
|
-
// content to its correct offset in the data set as a whole.
|
|
43
|
-
.anna-table-virtual-scroll-content-wrapper {
|
|
44
|
-
position: absolute;
|
|
45
|
-
top: 0;
|
|
46
|
-
left: 0;
|
|
47
|
-
contain: content;
|
|
48
|
-
// Note: We can't put `will-change: transform;` here because it causes Safari to not update the
|
|
49
|
-
// viewport's `scrollHeight` when the spacer's transform changes.
|
|
50
|
-
|
|
51
|
-
[dir="rtl"] & {
|
|
52
|
-
right: 0;
|
|
53
|
-
left: auto;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.app-table-virtual-scroll-orientation-horizontal
|
|
58
|
-
.anna-table-virtual-scroll-content-wrapper {
|
|
59
|
-
min-height: 100%;
|
|
60
|
-
@include _cdk-virtual-scroll-clear-container-space(horizontal);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.app-table-virtual-scroll-orientation-vertical
|
|
64
|
-
.anna-table-virtual-scroll-content-wrapper {
|
|
65
|
-
min-width: 100%;
|
|
66
|
-
@include _cdk-virtual-scroll-clear-container-space(vertical);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Spacer element that whose width or height will be adjusted to match the size of the entire data
|
|
70
|
-
// set if it were rendered all at once. This ensures that the scrollable content region is the
|
|
71
|
-
// correct size.
|
|
72
|
-
.app-table-virtual-scroll-spacer {
|
|
73
|
-
position: absolute;
|
|
74
|
-
top: 0;
|
|
75
|
-
left: 0;
|
|
76
|
-
height: 1px;
|
|
77
|
-
width: 1px;
|
|
78
|
-
transform-origin: 0 0;
|
|
79
|
-
|
|
80
|
-
// Note: We can't put `will-change: transform;` here because it causes Safari to not update the
|
|
81
|
-
// viewport's `scrollHeight` when the spacer's transform changes.
|
|
82
|
-
|
|
83
|
-
[dir="rtl"] & {
|
|
84
|
-
right: 0;
|
|
85
|
-
left: auto;
|
|
86
|
-
transform-origin: 100% 0;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { AnnaTableVirtualScrollViewportComponent } from './anna-table-virtual-scroll-viewport.component';
|
|
4
|
-
|
|
5
|
-
describe('AnnaTableVirtualScrollViewportComponent', () => {
|
|
6
|
-
let component: AnnaTableVirtualScrollViewportComponent;
|
|
7
|
-
let fixture: ComponentFixture<AnnaTableVirtualScrollViewportComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ AnnaTableVirtualScrollViewportComponent ]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
fixture = TestBed.createComponent(AnnaTableVirtualScrollViewportComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
fixture.detectChanges();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should create', () => {
|
|
23
|
-
expect(component).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { Directionality } from "@angular/cdk/bidi";
|
|
10
|
-
import { ListRange } from "@angular/cdk/collections";
|
|
11
|
-
import {
|
|
12
|
-
ChangeDetectionStrategy,
|
|
13
|
-
ChangeDetectorRef,
|
|
14
|
-
Component,
|
|
15
|
-
ElementRef,
|
|
16
|
-
Inject,
|
|
17
|
-
Input,
|
|
18
|
-
NgZone,
|
|
19
|
-
OnDestroy,
|
|
20
|
-
OnInit,
|
|
21
|
-
Optional,
|
|
22
|
-
Output,
|
|
23
|
-
ViewChild,
|
|
24
|
-
ViewEncapsulation
|
|
25
|
-
} from "@angular/core";
|
|
26
|
-
import {
|
|
27
|
-
animationFrameScheduler,
|
|
28
|
-
asapScheduler,
|
|
29
|
-
Observable,
|
|
30
|
-
Subject,
|
|
31
|
-
Observer,
|
|
32
|
-
Subscription
|
|
33
|
-
} from "rxjs";
|
|
34
|
-
import { auditTime, startWith, takeUntil } from "rxjs/operators";
|
|
35
|
-
import {
|
|
36
|
-
CdkVirtualScrollViewport,
|
|
37
|
-
CdkScrollable,
|
|
38
|
-
CdkVirtualScrollRepeater,
|
|
39
|
-
VIRTUAL_SCROLL_STRATEGY,
|
|
40
|
-
VirtualScrollStrategy,
|
|
41
|
-
ScrollDispatcher,
|
|
42
|
-
ViewportRuler,
|
|
43
|
-
ExtendedScrollToOptions
|
|
44
|
-
} from "@angular/cdk/scrolling";
|
|
45
|
-
import { AnnaGtHelperService } from '../../../anna-core-shared-lib/services/anna-generic-table.service';
|
|
46
|
-
|
|
47
|
-
/** Checks if the given ranges are equal. */
|
|
48
|
-
function rangesEqual(r1: ListRange, r2: ListRange): boolean {
|
|
49
|
-
return r1.start == r2.start && r1.end == r2.end;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Scheduler to be used for scroll events. Needs to fall back to
|
|
54
|
-
* something that doesn't rely on requestAnimationFrame on environments
|
|
55
|
-
* that don't support it (e.g. server-side rendering).
|
|
56
|
-
*/
|
|
57
|
-
const SCROLL_SCHEDULER =
|
|
58
|
-
typeof requestAnimationFrame !== "undefined"
|
|
59
|
-
? animationFrameScheduler
|
|
60
|
-
: asapScheduler;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* A viewport that virtualizes its scrolling with the help of `CdkVirtualForOf`.
|
|
64
|
-
* Uses `top: #px` instead of `transform: translateY(#px)` like the cdk virtual scroll viewport does
|
|
65
|
-
* which avoids flickering of elements in the transformed container with `position: sticky`.
|
|
66
|
-
*/
|
|
67
|
-
@Component({
|
|
68
|
-
selector: "anna-table-virtual-scroll-viewport",
|
|
69
|
-
templateUrl: "anna-table-virtual-scroll-viewport.component.html",
|
|
70
|
-
styleUrls: ["anna-table-virtual-scroll-viewport.component.scss"],
|
|
71
|
-
host: {
|
|
72
|
-
class: "anna-table-virtual-scroll-viewport",
|
|
73
|
-
"[class.anna-table-virtual-scroll-orientation-horizontal]":
|
|
74
|
-
'orientation === "horizontal"',
|
|
75
|
-
"[class.anna-table-virtual-scroll-orientation-vertical]":
|
|
76
|
-
'orientation !== "horizontal"'
|
|
77
|
-
},
|
|
78
|
-
encapsulation: ViewEncapsulation.None,
|
|
79
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
80
|
-
providers: [
|
|
81
|
-
{
|
|
82
|
-
provide: CdkScrollable,
|
|
83
|
-
useExisting: AnnaTableVirtualScrollViewportComponent
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
provide: CdkVirtualScrollViewport,
|
|
87
|
-
useExisting: AnnaTableVirtualScrollViewportComponent
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
})
|
|
91
|
-
export class AnnaTableVirtualScrollViewportComponent extends CdkScrollable
|
|
92
|
-
implements OnInit, OnDestroy {
|
|
93
|
-
/** Emits when the viewport is detached from a CdkVirtualForOf. */
|
|
94
|
-
private _detachedSubject = new Subject<void>();
|
|
95
|
-
|
|
96
|
-
/** Emits when the rendered range changes. */
|
|
97
|
-
private _renderedRangeSubject = new Subject<ListRange>();
|
|
98
|
-
|
|
99
|
-
/** The direction the viewport scrolls. */
|
|
100
|
-
@Input()
|
|
101
|
-
get orientation() {
|
|
102
|
-
return this._orientation;
|
|
103
|
-
}
|
|
104
|
-
set orientation(orientation: "horizontal" | "vertical") {
|
|
105
|
-
if (this._orientation !== orientation) {
|
|
106
|
-
this._orientation = orientation;
|
|
107
|
-
this._calculateSpacerSize();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
private _orientation: "horizontal" | "vertical" = "vertical";
|
|
111
|
-
|
|
112
|
-
// Note: we don't use the typical EventEmitter here because we need to subscribe to the scroll
|
|
113
|
-
// strategy lazily (i.e. only if the user is actually listening to the events). We do this because
|
|
114
|
-
// depending on how the strategy calculates the scrolled index, it may come at a cost to
|
|
115
|
-
// performance.
|
|
116
|
-
/** Emits when the index of the first element visible in the viewport changes. */
|
|
117
|
-
@Output() scrolledIndexChange: Observable<number> = new Observable(
|
|
118
|
-
(observer: Observer<number>) =>
|
|
119
|
-
this._scrollStrategy.scrolledIndexChange.subscribe(index =>
|
|
120
|
-
Promise.resolve().then(() =>
|
|
121
|
-
this.ngZone.run(() => observer.next(index))
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
/** The element that wraps the rendered content. */
|
|
127
|
-
@ViewChild("contentWrapper", { static: true }) _contentWrapper: ElementRef<
|
|
128
|
-
HTMLElement
|
|
129
|
-
>;
|
|
130
|
-
|
|
131
|
-
/** A stream that emits whenever the rendered range changes. */
|
|
132
|
-
renderedRangeStream: Observable<ListRange> = this._renderedRangeSubject;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* The total size of all content (in pixels), including content that is not currently rendered.
|
|
136
|
-
*/
|
|
137
|
-
private _totalContentSize = 0;
|
|
138
|
-
|
|
139
|
-
/** A string representing the `style.width` property value to be used for the spacer element. */
|
|
140
|
-
_totalContentWidth = "";
|
|
141
|
-
|
|
142
|
-
/** A string representing the `style.height` property value to be used for the spacer element. */
|
|
143
|
-
_totalContentHeight = "";
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* The CSS transform applied to the rendered subset of items so that they appear within the bounds
|
|
147
|
-
* of the visible viewport.
|
|
148
|
-
*/
|
|
149
|
-
private _renderedContentTransform: string;
|
|
150
|
-
|
|
151
|
-
/** The currently rendered range of indices. */
|
|
152
|
-
private _renderedRange: ListRange = { start: 0, end: 0 };
|
|
153
|
-
|
|
154
|
-
/** The length of the data bound to this viewport (in number of items). */
|
|
155
|
-
private _dataLength = 0;
|
|
156
|
-
|
|
157
|
-
/** The size of the viewport (in pixels). */
|
|
158
|
-
private _viewportSize = 0;
|
|
159
|
-
|
|
160
|
-
/** the currently attached CdkVirtualScrollRepeater. */
|
|
161
|
-
private _forOf: CdkVirtualScrollRepeater<any> | null;
|
|
162
|
-
|
|
163
|
-
/** The last rendered content offset that was set. */
|
|
164
|
-
private _renderedContentOffset = 0;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Whether the last rendered content offset was to the end of the content (and therefore needs to
|
|
168
|
-
* be rewritten as an offset to the start of the content).
|
|
169
|
-
*/
|
|
170
|
-
private _renderedContentOffsetNeedsRewrite = false;
|
|
171
|
-
|
|
172
|
-
/** Whether there is a pending change detection cycle. */
|
|
173
|
-
private _isChangeDetectionPending = false;
|
|
174
|
-
|
|
175
|
-
/** A list of functions to run after the next change detection cycle. */
|
|
176
|
-
private _runAfterChangeDetection: Function[] = [];
|
|
177
|
-
|
|
178
|
-
/** Subscription to changes in the viewport size. */
|
|
179
|
-
private _viewportChanges = Subscription.EMPTY;
|
|
180
|
-
|
|
181
|
-
constructor(
|
|
182
|
-
public override elementRef: ElementRef<HTMLElement>,
|
|
183
|
-
private _changeDetectorRef: ChangeDetectorRef,
|
|
184
|
-
ngZone: NgZone,
|
|
185
|
-
@Optional()
|
|
186
|
-
@Inject(VIRTUAL_SCROLL_STRATEGY)
|
|
187
|
-
private _scrollStrategy: VirtualScrollStrategy,
|
|
188
|
-
@Optional() dir: Directionality,
|
|
189
|
-
scrollDispatcher: ScrollDispatcher,
|
|
190
|
-
viewportRuler: ViewportRuler,
|
|
191
|
-
private annaGtService: AnnaGtHelperService
|
|
192
|
-
) {
|
|
193
|
-
super(elementRef, scrollDispatcher, ngZone, dir);
|
|
194
|
-
|
|
195
|
-
if (!_scrollStrategy) {
|
|
196
|
-
throw Error(
|
|
197
|
-
'Error: cdk-virtual-scroll-viewport requires the "itemSize" property to be set.'
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
this._viewportChanges = viewportRuler.change().subscribe(() => {
|
|
202
|
-
this.checkViewportSize();
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
override ngOnInit() {
|
|
207
|
-
super.ngOnInit();
|
|
208
|
-
|
|
209
|
-
// It's still too early to measure the viewport at this point. Deferring with a promise allows
|
|
210
|
-
// the Viewport to be rendered with the correct size before we measure. We run this outside the
|
|
211
|
-
// zone to avoid causing more change detection cycles. We handle the change detection loop
|
|
212
|
-
// ourselves instead.
|
|
213
|
-
this.ngZone.runOutsideAngular(() =>
|
|
214
|
-
Promise.resolve().then(() => {
|
|
215
|
-
this._measureViewportSize();
|
|
216
|
-
this._scrollStrategy.attach(this as any);
|
|
217
|
-
|
|
218
|
-
this.elementScrolled()
|
|
219
|
-
.pipe(
|
|
220
|
-
// Start off with a fake scroll event so we properly detect our initial position.
|
|
221
|
-
startWith(null),
|
|
222
|
-
// Collect multiple events into one until the next animation frame. This way if
|
|
223
|
-
// there are multiple scroll events in the same frame we only need to recheck
|
|
224
|
-
// our layout once.
|
|
225
|
-
auditTime(0, SCROLL_SCHEDULER)
|
|
226
|
-
)
|
|
227
|
-
.subscribe(() => { this._scrollStrategy.onContentScrolled(); this.annaGtService.virtualScrollSubject.next(true);});
|
|
228
|
-
|
|
229
|
-
this._markChangeDetectionNeeded();
|
|
230
|
-
})
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
override ngOnDestroy() {
|
|
235
|
-
this.detach();
|
|
236
|
-
this._scrollStrategy.detach();
|
|
237
|
-
|
|
238
|
-
// Complete all subjects
|
|
239
|
-
this._renderedRangeSubject.complete();
|
|
240
|
-
this._detachedSubject.complete();
|
|
241
|
-
this._viewportChanges.unsubscribe();
|
|
242
|
-
|
|
243
|
-
super.ngOnDestroy();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
|
|
247
|
-
attach(forOf: CdkVirtualScrollRepeater<any>) {
|
|
248
|
-
if (this._forOf) {
|
|
249
|
-
throw Error("CdkVirtualScrollViewport is already attached.");
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Subscribe to the data stream of the CdkVirtualForOf to keep track of when the data length
|
|
253
|
-
// changes. Run outside the zone to avoid triggering change detection, since we're managing the
|
|
254
|
-
// change detection loop ourselves.
|
|
255
|
-
this.ngZone.runOutsideAngular(() => {
|
|
256
|
-
this._forOf = forOf;
|
|
257
|
-
this._forOf.dataStream
|
|
258
|
-
.pipe(takeUntil(this._detachedSubject))
|
|
259
|
-
.subscribe(data => {
|
|
260
|
-
const newLength = data.length;
|
|
261
|
-
if (newLength !== this._dataLength) {
|
|
262
|
-
this._dataLength = newLength;
|
|
263
|
-
this._scrollStrategy.onDataLengthChanged();
|
|
264
|
-
}
|
|
265
|
-
this._doChangeDetection();
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/** Detaches the current `CdkVirtualForOf`. */
|
|
271
|
-
detach() {
|
|
272
|
-
this._forOf = null;
|
|
273
|
-
this._detachedSubject.next();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/** Gets the length of the data bound to this viewport (in number of items). */
|
|
277
|
-
getDataLength(): number {
|
|
278
|
-
return this._dataLength;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/** Gets the size of the viewport (in pixels). */
|
|
282
|
-
getViewportSize(): number {
|
|
283
|
-
return this._viewportSize;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// TODO(mmalerba): This is technically out of sync with what's really rendered until a render
|
|
287
|
-
// cycle happens. I'm being careful to only call it after the render cycle is complete and before
|
|
288
|
-
// setting it to something else, but its error prone and should probably be split into
|
|
289
|
-
// `pendingRange` and `renderedRange`, the latter reflecting whats actually in the DOM.
|
|
290
|
-
|
|
291
|
-
/** Get the current rendered range of items. */
|
|
292
|
-
getRenderedRange(): ListRange {
|
|
293
|
-
return this._renderedRange;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Sets the total size of all content (in pixels), including content that is not currently
|
|
298
|
-
* rendered.
|
|
299
|
-
*/
|
|
300
|
-
setTotalContentSize(size: number) {
|
|
301
|
-
if (this._totalContentSize !== size) {
|
|
302
|
-
this._totalContentSize = size;
|
|
303
|
-
this._calculateSpacerSize();
|
|
304
|
-
this._markChangeDetectionNeeded();
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/** Sets the currently rendered range of indices. */
|
|
309
|
-
setRenderedRange(range: ListRange) {
|
|
310
|
-
if (!rangesEqual(this._renderedRange, range)) {
|
|
311
|
-
this._renderedRangeSubject.next((this._renderedRange = range));
|
|
312
|
-
this._markChangeDetectionNeeded(() =>
|
|
313
|
-
this._scrollStrategy.onContentRendered()
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Gets the offset from the start of the viewport to the start of the rendered data (in pixels).
|
|
320
|
-
*/
|
|
321
|
-
getOffsetToRenderedContentStart(): number | null {
|
|
322
|
-
return this._renderedContentOffsetNeedsRewrite
|
|
323
|
-
? null
|
|
324
|
-
: this._renderedContentOffset;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Sets the offset from the start of the viewport to either the start or end of the rendered data
|
|
329
|
-
* (in pixels).
|
|
330
|
-
*/
|
|
331
|
-
setRenderedContentOffset(offset: number) {
|
|
332
|
-
let top = `${Number(offset)}px`;
|
|
333
|
-
this._renderedContentOffset = offset;
|
|
334
|
-
if (this._renderedContentTransform != top) {
|
|
335
|
-
// We know this value is safe because we parse `offset` with `Number()` before passing it
|
|
336
|
-
// into the string.
|
|
337
|
-
this._renderedContentTransform = top;
|
|
338
|
-
this._markChangeDetectionNeeded(() => {
|
|
339
|
-
if (this._renderedContentOffsetNeedsRewrite) {
|
|
340
|
-
this._renderedContentOffset -= this.measureRenderedContentSize();
|
|
341
|
-
this._renderedContentOffsetNeedsRewrite = false;
|
|
342
|
-
this.setRenderedContentOffset(this._renderedContentOffset);
|
|
343
|
-
} else {
|
|
344
|
-
this._scrollStrategy.onRenderedOffsetChanged();
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Scrolls to the given offset from the start of the viewport. Please note that this is not always
|
|
352
|
-
* the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left
|
|
353
|
-
* direction, this would be the equivalent of setting a fictional `scrollRight` property.
|
|
354
|
-
* @param offset The offset to scroll to.
|
|
355
|
-
* @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
|
|
356
|
-
*/
|
|
357
|
-
scrollToOffset(offset: number, behavior: ScrollBehavior = "auto") {
|
|
358
|
-
const options: ExtendedScrollToOptions = { behavior, top: offset };
|
|
359
|
-
this.scrollTo(options);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Scrolls to the offset for the given index.
|
|
364
|
-
* @param index The index of the element to scroll to.
|
|
365
|
-
* @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
|
|
366
|
-
*/
|
|
367
|
-
scrollToIndex(index: number, behavior: ScrollBehavior = "auto") {
|
|
368
|
-
this._scrollStrategy.scrollToIndex(index, behavior);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Gets the current scroll offset from the start of the viewport (in pixels).
|
|
373
|
-
* @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'
|
|
374
|
-
* in horizontal mode.
|
|
375
|
-
*/
|
|
376
|
-
// CHANGES@ANNALIB added override to functions
|
|
377
|
-
override measureScrollOffset(
|
|
378
|
-
from?: "top" | "left" | "right" | "bottom" | "start" | "end"
|
|
379
|
-
): number {
|
|
380
|
-
return from
|
|
381
|
-
? super.measureScrollOffset(from)
|
|
382
|
-
: super.measureScrollOffset("top");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/** Measure the combined size of all of the rendered items. */
|
|
386
|
-
measureRenderedContentSize(): number {
|
|
387
|
-
const contentEl = this._contentWrapper.nativeElement;
|
|
388
|
-
return contentEl.offsetHeight;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Measure the total combined size of the given range. Throws if the range includes items that are
|
|
393
|
-
* not rendered.
|
|
394
|
-
*/
|
|
395
|
-
measureRangeSize(range: ListRange): number {
|
|
396
|
-
if (!this._forOf) {
|
|
397
|
-
return 0;
|
|
398
|
-
}
|
|
399
|
-
return this._forOf.measureRangeSize(range, this.orientation);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/** Update the viewport dimensions and re-render. */
|
|
403
|
-
checkViewportSize() {
|
|
404
|
-
// TODO: Cleanup later when add logic for handling content resize
|
|
405
|
-
this._measureViewportSize();
|
|
406
|
-
this._scrollStrategy.onDataLengthChanged();
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/** Measure the viewport size. */
|
|
410
|
-
private _measureViewportSize() {
|
|
411
|
-
const viewportEl = this.elementRef.nativeElement;
|
|
412
|
-
this._viewportSize = viewportEl.clientHeight;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/** Queue up change detection to run. */
|
|
416
|
-
private _markChangeDetectionNeeded(runAfter?: Function) {
|
|
417
|
-
if (runAfter) {
|
|
418
|
-
this._runAfterChangeDetection.push(runAfter);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// Use a Promise to batch together calls to `_doChangeDetection`. This way if we set a bunch of
|
|
422
|
-
// properties sequentially we only have to run `_doChangeDetection` once at the end.
|
|
423
|
-
if (!this._isChangeDetectionPending) {
|
|
424
|
-
this._isChangeDetectionPending = true;
|
|
425
|
-
this.ngZone.runOutsideAngular(() =>
|
|
426
|
-
Promise.resolve().then(() => {
|
|
427
|
-
this._doChangeDetection();
|
|
428
|
-
})
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/** Run change detection. */
|
|
434
|
-
private _doChangeDetection() {
|
|
435
|
-
this._isChangeDetectionPending = false;
|
|
436
|
-
|
|
437
|
-
// Apply the content transform. The transform can't be set via an Angular binding because
|
|
438
|
-
// bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
|
|
439
|
-
// string literals, a variable that can only be 'X' or 'Y', and user input that is run through
|
|
440
|
-
// the `Number` function first to coerce it to a numeric value.
|
|
441
|
-
this._contentWrapper.nativeElement.style.top = this._renderedContentTransform;
|
|
442
|
-
// Apply changes to Angular bindings. Note: We must call `markForCheck` to run change detection
|
|
443
|
-
// from the root, since the repeated items are content projected in. Calling `detectChanges`
|
|
444
|
-
// instead does not properly check the projected content.
|
|
445
|
-
this.ngZone.run(() => this._changeDetectorRef.markForCheck());
|
|
446
|
-
|
|
447
|
-
const runAfterChangeDetection = this._runAfterChangeDetection;
|
|
448
|
-
this._runAfterChangeDetection = [];
|
|
449
|
-
for (const fn of runAfterChangeDetection) {
|
|
450
|
-
fn();
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/** Calculates the `style.width` and `style.height` for the spacer element. */
|
|
455
|
-
private _calculateSpacerSize() {
|
|
456
|
-
this._totalContentHeight = `${this._totalContentSize}px`;
|
|
457
|
-
this._totalContentWidth = "";
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|