Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {ErrorHandler, provideZoneChangeDetection} from '@angular/core';

import {LocationStrategy, PathLocationStrategy} from '@angular/common';
import {bootstrapApplication} from '@angular/platform-browser';
import {provideRouter, withComponentInputBinding, withInMemoryScrolling} from '@angular/router';
import {
provideRouter,
withComponentInputBinding,
withInMemoryScrolling,
withViewTransitions,
} from '@angular/router';
import {MaterialDocsApp} from './app/material-docs-app';
import {MATERIAL_DOCS_ROUTES} from './app/routes';
import {AnalyticsErrorReportHandler} from './app/shared/analytics/error-report-handler';
Expand All @@ -33,6 +38,9 @@ bootstrapApplication(MaterialDocsApp, {
// Binds route params (e.g. `:section` and `:id`) to inputs of the routed components. Nested
// routes also receive the params of their parent routes, since the router inherits them.
withComponentInputBinding(),
// Cross-fades between pages in browsers that support the View Transitions API. The first
// page load isn't animated, since there's no previous page to transition from.
withViewTransitions({skipInitialTransition: true}),
),
provideZoneChangeDetection(),
],
Expand Down
12 changes: 12 additions & 0 deletions docs/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ html {
@include api.api-styles;
@include markdown.markdown-styles;
@include tables.table-styles;

// Skip the cross-fade between pages (see `withViewTransitions` in `main.ts`) for users who
// prefer reduced motion. The new page then replaces the old one instantly.
@media (prefers-reduced-motion: reduce) {
// stylelint-disable selector-pseudo-element-no-unknown -- View Transitions pseudo-elements.
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
animation: none !important;
}
// stylelint-enable selector-pseudo-element-no-unknown
}
Loading