Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit a64482f

Browse files
willshowelljelbourn
authored andcommitted
Fix navbar shadow not showing on all routes (#225)
1 parent 5e3f6a0 commit a64482f

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/app/app-module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import {DocViewerModule} from './shared/doc-viewer/doc-viewer-module';
4848
DocViewerModule,
4949
FooterModule,
5050
GuideListModule,
51-
GuideListModule,
5251
GuideViewerModule,
5352
HomepageModule,
5453
NavBarModule,

src/app/material-docs-app.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component, ViewEncapsulation} from '@angular/core';
2-
import {Router, NavigationStart} from '@angular/router';
2+
import {Router, NavigationEnd} from '@angular/router';
3+
import 'rxjs/add/operator/filter';
34

45

56
@Component({
@@ -12,19 +13,24 @@ export class MaterialDocsApp {
1213
showShadow = false;
1314

1415
constructor(router: Router) {
16+
const routesWithNavbarShadow = ['/categories', '/components'];
17+
1518
let previousRoute = router.routerState.snapshot.url;
1619

17-
router.events.subscribe((data: NavigationStart) => {
18-
this.showShadow = data.url.startsWith('/components');
20+
router.events
21+
.filter(event => event instanceof NavigationEnd )
22+
.subscribe((data: NavigationEnd) => {
23+
this.showShadow = !!routesWithNavbarShadow
24+
.find(route => data.urlAfterRedirects.startsWith(route));
1925

20-
// We want to reset the scroll position on navigation except when navigating within
21-
// the documentation for a single component.
22-
if (!isNavigationWithinComponentView(previousRoute, data.url)) {
23-
resetScrollPosition();
24-
}
26+
// We want to reset the scroll position on navigation except when navigating within
27+
// the documentation for a single component.
28+
if (!isNavigationWithinComponentView(previousRoute, data.urlAfterRedirects)) {
29+
resetScrollPosition();
30+
}
2531

26-
previousRoute = data.url;
27-
});
32+
previousRoute = data.urlAfterRedirects;
33+
});
2834
}
2935
}
3036

src/app/pages/homepage/homepage.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h1 class="mat-h1">Angular Material</h1>
55
<h2> Material Design components for Angular</h2>
66
</div>
77
<div class="docs-header-start">
8-
<a md-raised-button class="docs-button" routerLink="guide/getting-started">Get started</a>
8+
<a md-raised-button class="docs-button" routerLink="/guide/getting-started">Get started</a>
99
</div>
1010
</div>
1111
</header>
@@ -59,7 +59,7 @@ <h2>Optimized for Angular</h2>
5959
</div>
6060
</div>
6161
<div class="docs-homepage-bottom-start">
62-
<a md-raised-button class="docs-button" routerLink="guide/getting-started">Get started</a>
62+
<a md-raised-button class="docs-button" routerLink="/guide/getting-started">Get started</a>
6363
</div>
6464
</div>
6565

0 commit comments

Comments
 (0)