Skip to content

Commit

Permalink
Fixes #68 (items not opening in several browsers)
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Mar 7, 2024
1 parent f0800c3 commit 2c176d6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions projects/chronomaps/src/app/chronomap/chronomap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,24 @@ export class ChronomapComponent implements OnInit, AfterViewInit, OnDestroy {
this.selectedItemId = item.id;
this.changing += 1;
this.actionSub?.unsubscribe();
let scrollBehavior: 'smooth' | 'auto' = 'smooth';
this.actionSub = timer(0).pipe(
tap(() => {
this.timeLineComponent?.scrollTo(item.timestamp, item);
}),
switchMap(() => {
const el = this.scrollerComponent.nativeElement as HTMLElement;
const behavior = this.detailOpen ? 'smooth' : 'auto';
scrollBehavior = this.detailOpen ? 'smooth' : 'auto';
const currentEl = el.querySelector('.current');
if (currentEl) {
currentEl.scrollIntoView({behavior, inline: 'center', block: 'center'});
return fromEvent(el, 'scrollend').pipe(
take(1),
);
} else {
return from([true]);
currentEl.scrollIntoView({behavior: scrollBehavior, inline: 'center', block: 'center'});
if (this.detailOpen) {
return fromEvent(el, 'scrollend').pipe(
take(1),
);
}
}
return from([true]);
}),
delay(0),//this.detailOpen ? 0 : 1000),
switchMap(() => {
Expand Down Expand Up @@ -318,7 +320,7 @@ export class ChronomapComponent implements OnInit, AfterViewInit, OnDestroy {
const el = this.scrollerComponent.nativeElement as HTMLElement;
const currentEl = el.querySelector('.current');
if (currentEl) {
currentEl.scrollIntoView({behavior: 'smooth', inline: 'center'});
currentEl.scrollIntoView({behavior: scrollBehavior, inline: 'center'});
}
}),
delay(3000),
Expand Down

0 comments on commit 2c176d6

Please sign in to comment.