Skip to content

Commit

Permalink
Merge pull request #489 from G-Core/WEB-4462
Browse files Browse the repository at this point in the history
Web 4462
  • Loading branch information
mariyayurlova authored Oct 24, 2023
2 parents d73e2fb + 8d992e3 commit ff4f2a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
47 changes: 22 additions & 25 deletions src/app/components/documentation/documentation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
NgZone,
OnDestroy,
OnInit,
Renderer2,
Expand Down Expand Up @@ -39,7 +38,6 @@ export class DocumentationComponent implements OnInit, AfterViewChecked, OnDestr
public tableOfContents: Array<TableOfContents> = [];
public tableOfContentsHeaders: Array<Element> = [];
public activeTocItem: string = '';
public showFullSizeImage: boolean = false;
public targetImageSrc: string = '';
public isMenuExpanded: boolean = false;
public category: string;
Expand All @@ -52,6 +50,7 @@ export class DocumentationComponent implements OnInit, AfterViewChecked, OnDestr
public isArticleReady: boolean = false;

private routerSubscription: Subscription;
private hasScrolled = false;

@ViewChild('scullyContainer') public scullyContainer: ElementRef;
@ViewChild('fullSizeImage') public fullSizeImage: ElementRef;
Expand All @@ -62,17 +61,12 @@ export class DocumentationComponent implements OnInit, AfterViewChecked, OnDestr
private route: ActivatedRoute,
private githubApiService: GitHubAPIService,
private viewportScroller: ViewportScroller,
private ngZone: NgZone,
private renderer: Renderer2,
private changeDetectorRef: ChangeDetectorRef,
private data: MenuService,
) {}

public ngAfterViewChecked(): void {
this.route.fragment.pipe(first()).subscribe((fragment) => {
this.viewportScroller.scrollToAnchor(fragment);
});

if (this.scullyContainer.nativeElement) {
if (this.scullyContainer.nativeElement.childElementCount > 1) {
this.isArticleReady = true;
Expand All @@ -82,31 +76,34 @@ export class DocumentationComponent implements OnInit, AfterViewChecked, OnDestr
this.changeDetectorRef.detectChanges();
}

this.scullyContainer.nativeElement.querySelectorAll(':not(.gc-gallery p) > img').forEach((img: Element) => {
this.ngZone.runOutsideAngular(() => {
this.renderer.listen(img, 'click', (event) => this.expandImage(event));
if (this.isArticleReady && !this.hasScrolled) {
this.route.fragment.pipe(first()).subscribe((fragment) => {
this.viewportScroller.scrollToAnchor(fragment);
this.hasScrolled = true;
});
});

this.ngZone.runOutsideAngular(() => {
this.scullyContainer.nativeElement
.querySelectorAll(':not(.gc-gallery p) > img')
.forEach((img: Element) => {
this.renderer.listen(img, 'click', (event) => this.expandImage(event));
});

window.document.addEventListener('scroll', this.handlePageScroll, true);
});

this.ngZone.runOutsideAngular(() => {
this.renderer.listen(this.fullSizeImage.nativeElement, 'click', () => this.closeFullSizeModal());
});

if (this.tableOfContents) {
this.tableOfContentsHeaders = this.tableOfContents
.map(({ fragment }) => {
if (fragment) {
return document.getElementById(`${fragment}`);
}
return null;
})
.filter((item: Element) => item);
}
}

if (this.isArticleReady && this.tableOfContents) {
this.tableOfContentsHeaders = this.tableOfContents
.map(({ fragment }) => {
if (fragment) {
return document.getElementById(`${fragment}`);
}
return null;
})
.filter((item: Element) => item);
}
}

public getAnchor(anchorIndex: number, pageUrl: string): string {
Expand Down
6 changes: 0 additions & 6 deletions src/app/components/left-bar-menu/left-bar-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
</ng-container>
</div>
<div class="side-nav-list-bottom {{ isHomePage ? 'side-nav-list-bottom_full' : '' }}">
<gc-redirect-link-button
class="side-nav-list-button"
[variant]="'secondary'"
[label]="'Support'"
[href]="'https://gcore.com/docs'"
></gc-redirect-link-button>
<gc-redirect-link-button
class="side-nav-list-button"
[variant]="'secondary'"
Expand Down

0 comments on commit ff4f2a5

Please sign in to comment.