toc auto-expand bug fix on description editor

This commit is contained in:
Sofia Papacharalampous 2024-05-22 16:58:06 +03:00
parent a5bc78f91d
commit 6a11832e2b
3 changed files with 8 additions and 5 deletions

View File

@ -9,7 +9,7 @@
<ng-container > <ng-container >
<span class="table-entry" <span class="table-entry"
(click)="onScrollStarted(entry); toggleExpand(idx);navigateToFieldSet(entry, $event); onEntrySelected(entry);" (click)="toggleExpand(idx);navigateToFieldSet(entry, $event); onEntrySelected(entry);"
[ngStyle]="calculateStyle(entry)" [ngStyle]="calculateStyle(entry)"
[ngClass]="calculateClass(entry)" [ngClass]="calculateClass(entry)"
> >

View File

@ -153,6 +153,7 @@ export class TableOfContentsInternal implements OnInit, OnDestroy {
navigateToFieldSet(entry: ToCEntry, event) { navigateToFieldSet(entry: ToCEntry, event) {
if (entry.type === ToCEntryType.FieldSet) { if (entry.type === ToCEntryType.FieldSet) {
this.onScrollStarted(entry);
const fieldSetId = entry.id; const fieldSetId = entry.id;
const element = document.getElementById(fieldSetId); const element = document.getElementById(fieldSetId);

View File

@ -210,7 +210,7 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
const options = { const options = {
root: null, root: null,
rootMargin: '-38% 0px -60% 0px', rootMargin: '20% 0px -30% 0px',
threshold: 0 threshold: 0
} }
@ -220,8 +220,6 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
} }
entries.forEach(ie => { entries.forEach(ie => {
if (this.isScrolling) return;
if (ie.isIntersecting) { if (ie.isIntersecting) {
try { try {
if(!this.isScrolling) { if(!this.isScrolling) {
@ -229,6 +227,8 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
if (this.visibilityRulesService.isVisibleMap[target_id] ?? true) { if (this.visibilityRulesService.isVisibleMap[target_id] ?? true) {
this.onToCentrySelected(this._findTocEntryById(target_id, this.tocentries)); this.onToCentrySelected(this._findTocEntryById(target_id, this.tocentries));
} }
} else {
console.log('cannot scroll');
} }
} catch { } catch {
} }
@ -445,10 +445,12 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
} }
onScrollStarted(entry: ToCEntry) { onScrollStarted(entry: ToCEntry) {
this.console.log('started');
this.isScrolling = true; this.isScrolling = true;
} }
onScrollFinished(entry: ToCEntry) { onScrollFinished(entry: ToCEntry) {
this.console.log('finished');
this.isScrolling = false; this.isScrolling = false;
} }