-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maksim Dolgikh
committed
Jan 4, 2024
1 parent
c12f6cf
commit 4b797dc
Showing
32 changed files
with
301 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"singleQuote": true | ||
"singleQuote": true, | ||
"printWidth": 80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,3 @@ | ||
<button (click)="show = !show" style="width: 100px;"> | ||
{{ show ? 'Hide' : 'Show'}} | ||
</button> | ||
|
||
<div style="display: flex; gap: 8px"> | ||
<app-item *ngIf="show" | ||
[@collapse]="options" | ||
(@collapse.start)="onAnimationEvent($event)" | ||
(@collapse.done)="onAnimationEvent($event)" | ||
> | ||
Angular animation item | ||
</app-item> | ||
|
||
<app-item | ||
class="css-animation" | ||
[ngClass]="show ? 'show' : 'hide'"> | ||
Css animation item | ||
</app-item> | ||
</div> | ||
<!--<app-reusable-animations></app-reusable-animations> Part 1--> | ||
<app-disable-animations></app-disable-animations> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
|
||
.show { | ||
opacity: 1; | ||
} | ||
|
||
.hide { | ||
opacity: 0; | ||
} | ||
|
||
.css-animation { | ||
transition: all 300ms linear; | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,12 @@ | ||
import { AnimationOptions, AnimationEvent } from '@angular/animations'; | ||
import { NgClass, NgIf } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { AN_COLLAPSE } from './animations/collapse'; | ||
import { ItemComponent } from './components/angular-animation/item.component'; | ||
import { ReusableAnimationsComponent } from './part-1/reusable-animations.component'; | ||
import { DisableAnimationsComponent } from './part-2/disable-animations.component'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ItemComponent, NgIf, NgClass], | ||
imports: [ReusableAnimationsComponent, DisableAnimationsComponent], | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrl: './app.component.scss', | ||
animations: [ | ||
AN_COLLAPSE | ||
] | ||
}) | ||
export class AppComponent { | ||
show = true | ||
|
||
options: AnimationOptions & { value: boolean } = { | ||
value: true, | ||
params: { | ||
duration: 400 | ||
} | ||
}; | ||
|
||
onAnimationEvent(event: AnimationEvent ) { | ||
switch (event.phaseName) { | ||
case 'start': { | ||
console.time('animation'); | ||
break | ||
} | ||
case 'done': { | ||
console.timeEnd('animation'); | ||
break; | ||
} | ||
default: { | ||
break | ||
} | ||
} | ||
} | ||
} | ||
export class AppComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
animate, | ||
animation, | ||
AnimationOptions, | ||
style, | ||
transition, | ||
trigger, | ||
} from '@angular/animations'; | ||
|
||
const closedStyle = style({ height: 0 }); | ||
const openStyle = style({ height: '*' }); | ||
const animateTimings = '{{duration}}ms linear'; | ||
const defaultOptions: AnimationOptions = { params: { duration: 300 } }; | ||
|
||
export const collapse = trigger('collapse', [ | ||
transition( | ||
':enter', | ||
animation([closedStyle, animate(animateTimings, openStyle)]), | ||
defaultOptions | ||
), | ||
transition( | ||
':leave', | ||
animation([openStyle, animate(animateTimings, closedStyle)]), | ||
defaultOptions | ||
), | ||
]); | ||
|
||
export interface ReusableAnimationOptions<State> extends AnimationOptions { | ||
value?: State; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ng-content></ng-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
align-items: center; | ||
background: #f3dfdf; | ||
width: 100px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { collapse, ReusableAnimationOptions } from '../../animations/collapse'; | ||
|
||
@Component({ | ||
selector: 'app-bonus', | ||
standalone: true, | ||
imports: [CommonModule], | ||
templateUrl: './bonus.component.html', | ||
styleUrl: './bonus.component.scss', | ||
animations: [collapse], | ||
host: { | ||
'[@collapse]': 'animationOptions', | ||
}, | ||
}) | ||
export class BonusComponent implements OnInit { | ||
@Input() | ||
public collapseDuration: number = 300; | ||
|
||
public animationOptions!: ReusableAnimationOptions<string> | ||
|
||
public ngOnInit(): void { | ||
this.animationOptions = { | ||
value: '_', | ||
params: { duration: this.collapseDuration }, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="flex"> | ||
<button (click)="state = !state">{{ | ||
state ? 'close' : 'open' | ||
}}</button> | ||
</div> | ||
|
||
<div class="flex"> | ||
<div *ngIf="state" class="example-block" [@collapse]="slowAnimation"> | ||
<div class="block">Slow</div> | ||
</div> | ||
<div *ngIf="state" class="example-block" [@collapse]="fastAnimation"> | ||
<div class="block">Fast</div> | ||
</div> | ||
</div> | ||
|
||
<div class="flex"> | ||
<ng-container *ngFor="let duration of durations"> | ||
<app-bonus *ngIf="state" [collapseDuration]="duration"> | ||
<div class="block">Duration {{duration}} ms</div> | ||
</app-bonus> | ||
</ng-container> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
:host { | ||
.example-block { | ||
background: #b59e9e; | ||
width: 100px; | ||
} | ||
|
||
.block { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { collapse, ReusableAnimationOptions } from './animations/collapse'; | ||
import { BonusComponent } from './components/bonus/bonus.component'; | ||
|
||
@Component({ | ||
selector: 'app-reusable-animations', | ||
standalone: true, | ||
imports: [CommonModule, BonusComponent], | ||
templateUrl: './reusable-animations.component.html', | ||
styleUrl: './reusable-animations.component.scss', | ||
animations: [collapse], | ||
host: { | ||
'[class.flex]': 'true', | ||
'[class.flex-column]': 'true', | ||
}, | ||
}) | ||
export class ReusableAnimationsComponent { | ||
public state: boolean = false; | ||
public slowAnimation: ReusableAnimationOptions<string> = { | ||
value: '_', | ||
params: { duration: 800 }, | ||
}; | ||
public fastAnimation: ReusableAnimationOptions<string> = { | ||
value: '_', | ||
params: { duration: 200 }, | ||
}; | ||
|
||
public durations = [1000, 800, 600, 400, 200, 0] | ||
} |
Oops, something went wrong.