-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from cloudinary/ME-4642-fix-opacity-action
Fix opacity action (missing actionModel)
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 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,16 +1,31 @@ | ||
import {Action} from "../../internal/Action.js"; | ||
import {Qualifier} from "../../internal/qualifier/Qualifier.js"; | ||
import {OpacityActionModel} from "../../internal/models/IOpacityActionModel.js"; | ||
import {IActionModel} from "../../internal/models/IActionModel.js"; | ||
|
||
/** | ||
* @description OpacityAction class, used to define the opacity of an asset | ||
* @memberOf Actions.Adjust | ||
* @extends SDK.Action | ||
*/ | ||
class OpacityAdjustAction extends Action { | ||
private level: number; | ||
protected _actionModel: OpacityActionModel = {actionType: 'opacity'}; | ||
|
||
constructor(level: number) { | ||
super(); | ||
this.level = level; | ||
this._actionModel.level = level; | ||
this.addQualifier(new Qualifier('o', level)); | ||
} | ||
|
||
static fromJson(actionModel: IActionModel): OpacityAdjustAction { | ||
const { level } = (actionModel as OpacityActionModel); | ||
|
||
// We are using this() to allow inheriting classes to use super.fromJson.apply(this, [actionModel]) | ||
// This allows the inheriting classes to determine the class to be created | ||
return new this(level); | ||
} | ||
} | ||
|
||
export {OpacityAdjustAction}; |
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,7 @@ | ||
import {IActionModel} from "./IActionModel.js"; | ||
|
||
interface OpacityActionModel extends IActionModel { | ||
level?: number; | ||
} | ||
|
||
export {OpacityActionModel}; |