Skip to content

Commit

Permalink
Fixed issue when first page is incorrectly set on loading next file
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-litvinchik committed Sep 28, 2024
1 parent 31deed5 commit 8925fd7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions libs/common-components/src/lib/scrollable-edited.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ export class ScrollableEditedDirective implements AfterViewInit, OnChanges {
scrollToPage(pageNumber: number) {
const el = this._elementRef.nativeElement;
const pages = this.getChildren();
const pageIsInViewport = this._viewportService.isBelowCenterOfTheScreen(pages.item(pageNumber - 1) as HTMLElement, this._elementRef.nativeElement);
const htmlElement = pages.item(pageNumber - 1) as HTMLElement;
if(!htmlElement) {
return;
}

const pageIsInViewport = this._viewportService.isBelowCenterOfTheScreen(htmlElement, this._elementRef.nativeElement);

if (pageIsInViewport) {
return;
Expand Down Expand Up @@ -111,10 +116,13 @@ export class ScrollableEditedDirective implements AfterViewInit, OnChanges {
}
break;
}

const pageIsInViewport = this._viewportService.isBelowCenterOfTheScreen(pages.item(counter) as HTMLElement, this._elementRef.nativeElement);
const htmlElement = pages.item(counter) as HTMLElement;
if(!htmlElement) {
break;
}
const pageIsInViewport = this._viewportService.isBelowCenterOfTheScreen(htmlElement, this._elementRef.nativeElement);
if (pageIsInViewport) {
pageNum = counter + 1;
pageNum = counter + 1;
} else if (pageNum) {
counter = pages.length
}
Expand All @@ -130,9 +138,9 @@ export class ScrollableEditedDirective implements AfterViewInit, OnChanges {
}
}

if ((this.isPresentation && this._navigateService.currentPage === 0) || !this.isPresentation) {
this._navigateService.currentPage = pageNum;
}
// if ((this.isPresentation && this._navigateService.currentPage === 0) || !this.isPresentation) {
// this._navigateService.currentPage = pageNum;
// }
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down

0 comments on commit 8925fd7

Please sign in to comment.