11import { LeveledEffectAction } from "../EffectActions/LeveledEffectAction.js" ;
2+ import { Action } from "../../../internal/Action.js" ;
3+ import { Qualifier } from "../../../internal/qualifier/Qualifier.js" ;
4+ import { QualifierValue } from "../../../internal/qualifier/QualifierValue.js" ;
5+ import { IFadeOutEffectActionModel } from "../../../internal/models/IEffectActionModel.js" ;
6+ import { IActionModel } from "../../../internal/models/IActionModel.js" ;
27
38
49/**
@@ -7,12 +12,33 @@ import {LeveledEffectAction} from "../EffectActions/LeveledEffectAction.js";
712 * @memberOf Actions.Effect
813 * @see Visit {@link Actions.Effect|Effect} for an example
914 */
10- class FadeoutEffectAction extends LeveledEffectAction {
11- // We can't use EffectActionWithLength because this `length` is reversing the sign
12- duration ( value : number | string ) : this {
13- return this . setLevel ( - value ) ;
15+ class FadeOutEffectAction extends Action {
16+ protected _actionModel : IFadeOutEffectActionModel = { actionType : 'fadeOut' } ;
17+ constructor ( duration : number ) {
18+ super ( ) ;
19+ this . addQualifier ( new Qualifier ( 'e' , new QualifierValue ( [ 'fade' , `-${ duration } ` ] ) . setDelimiter ( ':' ) ) ) ;
20+ duration && ( this . _actionModel . length = duration ) ;
21+ }
22+ /**
23+ *
24+ * @description Sets the duration level for the action
25+ * @param {string | number } duration - The duration of the effect
26+ */
27+ duration ( duration : number | string ) : this {
28+ this . _actionModel . length = duration as number ;
29+ return this . addQualifier ( new Qualifier ( 'e' , new QualifierValue ( [ 'fade' , `-${ duration } ` ] ) . setDelimiter ( ':' ) ) ) ;
30+ }
31+
32+ static fromJson ( actionModel : IActionModel ) : FadeOutEffectAction {
33+ const { length} = ( actionModel as IFadeOutEffectActionModel ) ;
34+
35+ // We are using this() to allow inheriting classes to use super.fromJson.apply(this, [actionModel])
36+ // This allows the inheriting classes to determine the class to be created
37+ const result = new this ( length ) ;
38+
39+ return result ;
1440 }
1541}
1642
1743
18- export { FadeoutEffectAction } ;
44+ export { FadeOutEffectAction } ;
0 commit comments