Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit699e701

Browse files
committed
refactor(toast): remove: onAnimationEvent()@fadeinout.start @fadeInOut.done, cleanup
1 parentbf8e1ef commit699e701

File tree

1 file changed

+26
-45
lines changed

1 file changed

+26
-45
lines changed

‎projects/coreui-angular/src/lib/toast/toast/toast.component.ts‎

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,59 @@ import {
99
OnDestroy,
1010
OnInit,
1111
Output,
12-
Renderer2,
12+
Renderer2
1313
}from'@angular/core';
1414

15-
import{animate,AnimationEvent,state,style,transition,trigger}from'@angular/animations';
15+
import{animate,state,style,transition,trigger}from'@angular/animations';
1616
import{BooleanInput,coerceBooleanProperty}from'@angular/cdk/coercion';
1717

18+
import{Colors}from'../../coreui.types';
1819
import{ToasterService}from'../toaster/toaster.service';
1920
import{TToasterPlacement}from'../toaster/toaster.component';
20-
import{Colors}from'../../coreui.types';
2121

2222
typeAnimateType=('hide'|'show');
2323

2424
@Component({
2525
selector:'c-toast',
26-
template:`<ng-content></ng-content>`,
26+
template:'<ng-content></ng-content>',
2727
styleUrls:['./toast.component.scss'],
2828
exportAs:'cToast',
2929
standalone:true,
3030
animations:[
3131
trigger('fadeInOut',[
32-
state('show',style({opacity:1,height:'*',padding:'*',border:'*',margin:'*'})),
33-
state('hide',style({opacity:0,height:0,padding:0,border:0,margin:0})),
34-
state('void',style({opacity:0,height:0,padding:0,border:0,margin:0})),
32+
state('show',style({opacity:1,height:'*',padding:'*',border:'*',margin:'*'})),
33+
state('hide',style({opacity:0,height:0,padding:0,border:0,margin:0})),
34+
state('void',style({opacity:0,height:0,padding:0,border:0,margin:0})),
3535
transition('show => hide',[
36-
animate('{{ time }} {{ easing }}'),
36+
animate('{{ time }} {{ easing }}')
3737
],{
38-
params:{time:'300ms',easing:'ease-out'}
38+
params:{time:'300ms',easing:'ease-out'}
3939
}),
4040
transition('hide => show',[animate('{{ time }} {{ easing }}')],{
41-
params:{time:'300ms',easing:'ease-in'},
41+
params:{time:'300ms',easing:'ease-in'}
4242
}),
4343
transition('show => void',[animate('{{ time }} {{ easing }}')],{
44-
params:{time:'300ms',easing:'ease-out'},
44+
params:{time:'300ms',easing:'ease-out'}
4545
}),
4646
transition('void => show',[animate('{{ time }} {{ easing }}')],{
47-
params:{time:'300ms',easing:'ease-in'},
48-
}),
49-
]),
50-
],
47+
params:{time:'300ms',easing:'ease-in'}
48+
})
49+
])
50+
]
5151
})
5252
exportclassToastComponentimplementsOnInit,OnDestroy{
5353

5454
staticngAcceptInputType_visible:BooleanInput;
5555

5656
publicdynamic!:boolean;
5757
publicplacement!:TToasterPlacement;
58-
publichide!:boolean;
58+
59+
constructor(
60+
publichostElement:ElementRef,
61+
publicrenderer:Renderer2,
62+
publictoasterService:ToasterService,
63+
publicchangeDetectorRef:ChangeDetectorRef
64+
){}
5965

6066
/**
6167
* Auto hide the toast.
@@ -95,9 +101,11 @@ export class ToastComponent implements OnInit, OnDestroy {
95101
this.changeDetectorRef.markForCheck();
96102
}
97103
}
104+
98105
getvisible(){
99106
returnthis._visible;
100107
}
108+
101109
private_visible=false;
102110

103111
/**
@@ -121,13 +129,6 @@ export class ToastComponent implements OnInit, OnDestroy {
121129
privateclockId:any;
122130
privateclockTimerId:any;
123131

124-
constructor(
125-
publichostElement:ElementRef,
126-
publicrenderer:Renderer2,
127-
publictoasterService:ToasterService,
128-
publicchangeDetectorRef:ChangeDetectorRef
129-
){}
130-
131132
private_clock!:number;
132133

133134
getclock():number{
@@ -150,16 +151,6 @@ export class ToastComponent implements OnInit, OnDestroy {
150151
returnthis.visible ?'show' :'hide';
151152
}
152153

153-
@HostListener('@fadeInOut.start',['$event'])
154-
onAnimationStart($event:AnimationEvent):void{
155-
this.onAnimationEvent($event);
156-
}
157-
158-
@HostListener('@fadeInOut.done',['$event'])
159-
onAnimationDone($event:AnimationEvent):void{
160-
this.onAnimationEvent($event);
161-
}
162-
163154
@HostListener('mouseover')onMouseOver():void{
164155
this.clearTimer();
165156
}
@@ -183,7 +174,7 @@ export class ToastComponent implements OnInit, OnDestroy {
183174
this.toasterService.setState({
184175
toast:this,
185176
show:this.visible,
186-
placement:this.placement,
177+
placement:this.placement
187178
});
188179
this.clearTimer();
189180
this.setTimer();
@@ -213,7 +204,7 @@ export class ToastComponent implements OnInit, OnDestroy {
213204
this.toasterService.setState({
214205
toast:this,
215206
show:false,
216-
placement:this.placement,
207+
placement:this.placement
217208
});
218209
}
219210

@@ -234,14 +225,4 @@ export class ToastComponent implements OnInit, OnDestroy {
234225
clearInterval(this.clockId);
235226
this.clockId=null;
236227
}
237-
238-
onAnimationEvent(event:AnimationEvent):void{
239-
this.hide=event.phaseName==='start'&&event.toState==='show';
240-
if(event.phaseName==='done'){
241-
this.hide=(event.toState==='hide'||event.toState==='void');
242-
if(event.toState==='show'){
243-
this.hide=false;
244-
}
245-
}
246-
}
247228
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp