Skip to content

Commit 6078d9c

Browse files
committed
Native CSS animation instead of @angular/animations #11561
1 parent 5090a83 commit 6078d9c

File tree

7 files changed

+26
-59
lines changed

7 files changed

+26
-59
lines changed

client/app/front-office/components/menu/menu.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="mega-menu mat-elevation-z4" role="menu" [@transformMenu]="panelAnimationState">
1+
<div class="mega-menu mat-elevation-z4" role="menu">
22
<div class="mega-menu-content" [style.min-height.px]="data.contentHeight" [style.padding-left.px]="offsetLeft">
33
<ng-container *ngTemplateOutlet="navigationTemplate; context: {$implicit: data.items}" />
44
</div>

client/app/front-office/components/menu/menu.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
@keyframes _mat-menu-enter {
2+
from {
3+
transform: scale(0.8);
4+
opacity: 0;
5+
}
6+
7+
to {
8+
transform: none;
9+
opacity: 1;
10+
}
11+
}
12+
113
:host {
214
display: flex;
315
flex: 1;
@@ -6,6 +18,7 @@
618
.mega-menu {
719
display: block;
820
flex: 1;
21+
animation: _mat-menu-enter 120ms cubic-bezier(0, 0, 0.2, 1);
922
border-radius: 5px;
1023
background: white;
1124
padding-top: 15px;

client/app/front-office/components/menu/menu.component.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {animate, group, query, sequence, state, style, transition, trigger} from '@angular/animations';
21
import {ChangeDetectionStrategy, Component, inject, InjectionToken} from '@angular/core';
32
import {MenuItem} from '../../services/navigation.service';
43
import {RouterLink, RouterLinkActive} from '@angular/router';
@@ -18,26 +17,6 @@ export const APP_MENU_DATA = new InjectionToken<MenuDropdownData>('MenuDropdownD
1817
styleUrl: './menu.component.scss',
1918
changeDetection: ChangeDetectionStrategy.OnPush,
2019
preserveWhitespaces: false,
21-
animations: [
22-
trigger('transformMenu', [
23-
state('void', style({opacity: 0, transform: 'scale(0.01, 0.01)'})),
24-
transition(
25-
'void => enter',
26-
sequence([
27-
query('.mega-menu-content', style({opacity: 0})),
28-
animate('100ms linear', style({opacity: 1, transform: 'scale(1, 0.5)'})),
29-
group([
30-
query(
31-
'.mega-menu-content',
32-
animate('402ms cubic-bezier(0.55, 0, 0.55, 0.2)', style({opacity: 1})),
33-
),
34-
animate('300ms cubic-bezier(0.25, 0.8, 0.25, 1)', style({transform: 'scale(1, 1)'})),
35-
]),
36-
]),
37-
),
38-
transition('* => void', animate('150ms 50ms linear', style({opacity: 0}))),
39-
]),
40-
],
4120
imports: [CommonModule, RouterLinkActive, RouterLink],
4221
})
4322
export class MenuComponent {
@@ -48,21 +27,12 @@ export class MenuComponent {
4827
*/
4928
public offsetLeft = 0;
5029

51-
/**
52-
* Current state of the panel animation.
53-
*/
54-
public panelAnimationState: 'void' | 'enter' = 'void';
55-
5630
public constructor() {
5731
const data = this.data;
5832

5933
this.offsetLeft = data.originalNativeElement.offsetLeft - 20;
6034
}
6135

62-
public startAnimation(): void {
63-
this.panelAnimationState = 'enter';
64-
}
65-
6636
/**
6737
* Toggle open parent nodes, and allow navigation only on children
6838
*/

client/app/front-office/services/navigation.service.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Overlay, OverlayConfig} from '@angular/cdk/overlay';
22
import {ComponentPortal} from '@angular/cdk/portal';
33
import {DOCUMENT} from '@angular/common';
4-
import {ComponentRef, ElementRef, inject, Injectable, Injector, StaticProvider} from '@angular/core';
4+
import {ElementRef, inject, Injectable, Injector, StaticProvider} from '@angular/core';
55
import {NavigationEnd, Router, RouterLink} from '@angular/router';
66
import {cloneDeep} from 'lodash-es';
77
import {merge, Observable, Subject} from 'rxjs';
@@ -57,16 +57,12 @@ export class NavigationService {
5757
.top(offsetTop + 'px')
5858
.centerHorizontally(),
5959
hasBackdrop: true,
60-
// backdropClass: 'cdk-overlay-transparent-backdrop',
6160
});
6261

6362
// Container
6463
const overlayRef = this.overlay.create(overlayConfig);
6564
const containerPortal = new ComponentPortal(MenuComponent, undefined, containerInjector);
66-
const containerRef: ComponentRef<MenuComponent> = overlayRef.attach(containerPortal);
67-
68-
// Start animation that shows menu
69-
containerRef.instance.startAnimation();
65+
overlayRef.attach(containerPortal);
7066

7167
// use subject because backdropClick() subscription don't allow two subscriptions (
7268
const onBackdropClick = new Subject<void>();

client/main.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {APP_ID, inject, LOCALE_ID, provideAppInitializer, provideZoneChangeDetection} from '@angular/core';
22
import {AppComponent} from './app/app.component';
33
import {routes} from './app/app-routing.module';
4-
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
54
import {bootstrapApplication} from '@angular/platform-browser';
65
import {Apollo} from 'apollo-angular';
76
import {MAT_TOOLTIP_DEFAULT_OPTIONS, MatTooltipDefaultOptions} from '@angular/material/tooltip';
@@ -40,14 +39,11 @@ const matTooltipCustomConfig: MatTooltipDefaultOptions = {
4039
touchGestures: 'off',
4140
};
4241

43-
const prefersReducedMotion = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion)').matches : false;
44-
4542
bootstrapApplication(AppComponent, {
4643
providers: [
4744
provideZoneChangeDetection({eventCoalescing: true}),
4845
provideNativeDateAdapter(),
4946
Apollo,
50-
provideAnimationsAsync(prefersReducedMotion ? 'noop' : 'animations'),
5147
naturalProviders,
5248
provideErrorHandler(localConfig.log.url, LoggerExtraService),
5349
provideSeo({

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"codegen": "./bin/dump-schema && graphql-codegen --config codegen.ts"
1616
},
1717
"dependencies": {
18-
"@angular/animations": "^19.2.13",
1918
"@angular/cdk": "^19.2.17",
2019
"@angular/common": "^19.2.13",
2120
"@angular/compiler": "^19.2.13",
@@ -28,8 +27,8 @@
2827
"@angular/router": "^19.2.13",
2928
"@apollo/client": "^3.13.7",
3029
"@ecodev/fab-speed-dial": "^18.0.0",
31-
"@ecodev/natural": "^63.4.0",
32-
"@ecodev/natural-editor": "^63.4.0",
30+
"@ecodev/natural": "^63.5.1",
31+
"@ecodev/natural-editor": "^63.5.1",
3332
"@ecodev/natural-layout": "^2.0.2",
3433
"@graphql-codegen/cli": "^5.0.5",
3534
"@graphql-codegen/typescript-apollo-angular": "^4.0.0",

yarn.lock

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,6 @@
202202
dependencies:
203203
"@angular-eslint/bundled-angular-compiler" "19.3.0"
204204

205-
"@angular/animations@^19.2.13":
206-
version "19.2.13"
207-
resolved "https://registry.yarnpkg.com/@angular/animations/-/animations-19.2.13.tgz#8df70342e29a51b85ed1a15c716240b004e4b906"
208-
integrity sha512-x9LYcSndY9BdwuRxTx0gXvlLrvJyzjnWoaIoVLrAZWZbKfQh2+HK4XkclbzNvn8RMeoBpZZatcC3ZBC1TffjtA==
209-
dependencies:
210-
tslib "^2.3.0"
211-
212205
"@angular/build@19.2.13":
213206
version "19.2.13"
214207
resolved "https://registry.yarnpkg.com/@angular/build/-/build-19.2.13.tgz#0b9dc22ba303ce29ec45fadd3ff60a651c588614"
@@ -1333,10 +1326,10 @@
13331326
dependencies:
13341327
tslib "^2.8.1"
13351328

1336-
"@ecodev/natural-editor@^63.4.0":
1337-
version "63.4.0"
1338-
resolved "https://registry.yarnpkg.com/@ecodev/natural-editor/-/natural-editor-63.4.0.tgz#16eff30e9ac8642f4909a2c3fbd497da26867ee3"
1339-
integrity sha512-seJuku1CHNCf+SUE8CVCX1WuiEmzVKHgnGkNU+cDiBMhraZVFH0orOAcP7Umz8nAVt3A62FdgNPCWP6cWSynpw==
1329+
"@ecodev/natural-editor@^63.5.1":
1330+
version "63.5.1"
1331+
resolved "https://registry.yarnpkg.com/@ecodev/natural-editor/-/natural-editor-63.5.1.tgz#3d7817412d7aa986765903ee92371d352f8dd65c"
1332+
integrity sha512-i7kstOAaDRzQ3JAtvUU3oXSK/tkuGQz1w2r24k8P44ltcPXz6fFAIAa4FmkcQcpXC8yP58gJ+T9e/ft/N0jwFA==
13401333
dependencies:
13411334
prosemirror-commands "^1.5.2"
13421335
prosemirror-dropcursor "^1.8.1"
@@ -1358,10 +1351,10 @@
13581351
resolved "https://registry.yarnpkg.com/@ecodev/natural-layout/-/natural-layout-2.0.2.tgz#e2c64c2ddb3c60793a39236b52624fde323e610a"
13591352
integrity sha512-BV75kFQmpfuSBNQ1jyKu+IdGkFTMESjPrtKrEyc3MqcmVhV5IiYU0LXTaghLZozuZgCT9HfMOnEsh05aS2j9uQ==
13601353

1361-
"@ecodev/natural@^63.4.0":
1362-
version "63.4.0"
1363-
resolved "https://registry.yarnpkg.com/@ecodev/natural/-/natural-63.4.0.tgz#efa100f8de9d68fa9411cb79cf5786d19adc9fc4"
1364-
integrity sha512-0ux68Dxi1IJD42ShzIbWSOoFD/aY49z9VunDYFBzJCUSAQ4BGawhJR1aQX+9xbJHqx8rs5zmhyAI3QFCUJjnvg==
1354+
"@ecodev/natural@^63.5.1":
1355+
version "63.5.1"
1356+
resolved "https://registry.yarnpkg.com/@ecodev/natural/-/natural-63.5.1.tgz#d7bcedbd91daad69fc03fccc8d3f7689a33ed85b"
1357+
integrity sha512-F3KIqRkksf4wv4M6nKqjolYwyW24hkcsthZn4C3yUyiKQVZ7zWGhXpeLfzjLDl10rbtpDnV0+vmcGJ/BL15W6Q==
13651358
dependencies:
13661359
extract-files "^13.0.0"
13671360
tslib "^2.8.1"

0 commit comments

Comments
 (0)