Fixed enable/disable quick nav buttons

This commit is contained in:
Adina Țeudan 2021-03-18 23:41:10 +02:00
parent f26c1e67ad
commit a4b3bd498d
2 changed files with 9 additions and 7 deletions

View File

@ -229,7 +229,7 @@
>
<mat-icon svgIcon="red:nav-first"></mat-icon>
</div>
<div class="pages" (scroll)="onQuickNavScroll($event)">
<div class="pages" (scroll)="computeQuickNavButtonsState()" id="pages">
<redaction-page-indicator
(pageSelected)="pageSelectedByClick($event)"
*ngFor="let pageNumber of displayedPages"

View File

@ -367,12 +367,6 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy {
}
}
public onQuickNavScroll($event) {
const { scrollHeight, scrollTop, clientHeight } = $event.target;
this.quickScrollFirstEnabled = scrollTop !== 0;
this.quickScrollLastEnabled = scrollHeight !== scrollTop + clientHeight;
}
private _scrollAnnotations() {
if (this.firstSelectedAnnotation?.pageNumber === this.activeViewerPage) {
return;
@ -597,6 +591,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy {
filtersChanged(filters: FilterModel[]) {
this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(this.annotations, filters);
this.displayedPages = Object.keys(this.displayedAnnotations).map((key) => Number(key));
this.computeQuickNavButtonsState();
this._changeDetectorRef.markForCheck();
}
@ -606,6 +601,13 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy {
}
}
public computeQuickNavButtonsState() {
const element: HTMLElement = this._quickNavigationElement.nativeElement.querySelector(`#pages`);
const { scrollTop, scrollHeight, clientHeight } = element;
this.quickScrollFirstEnabled = scrollTop !== 0;
this.quickScrollLastEnabled = scrollHeight !== scrollTop + clientHeight;
}
private _cleanupAndRedrawManualAnnotations() {
this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => {
this.fileData.manualRedactions = manualRedactions;