Skip to content

Commit 41c2f03

Browse files
committed
add deshake toJson
1 parent 5bd543b commit 41c2f03

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

__TESTS__/unit/toJson/effect.toJson.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,15 @@ describe('Effect toJson()', () => {
257257
}
258258
]);
259259
});
260+
261+
it('effect.deshake', () => {
262+
const transformation = new Transformation()
263+
.addAction(Effect.deshake().shakeStrength(16));
264+
expect(transformation.toJson()).toStrictEqual( [
265+
{
266+
actionType: 'deshake',
267+
pixels: 16
268+
}
269+
]);
270+
});
260271
});

src/actions/effect/leveled/Deshake.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {LeveledEffectAction} from "../EffectActions/LeveledEffectAction.js";
22
import {ExpressionQualifier} from "../../../qualifiers/expression/ExpressionQualifier.js";
3+
import {IDeshakeEffectModel} from "../../../internal/models/IEffectActionModel.js";
34

45
/**
56
* @description Removes small motion shifts from the video. with a maximum extent of movement in the horizontal and vertical direction of 32 pixels
@@ -8,12 +9,16 @@ import {ExpressionQualifier} from "../../../qualifiers/expression/ExpressionQual
89
* @see Visit {@link Actions.Effect|Effect} for an example
910
*/
1011
class DeshakeEffectAction extends LeveledEffectAction {
12+
protected _actionModel: IDeshakeEffectModel = {actionType: 'deshake'};
1113
/**
1214
* The maximum number of pixels in the horizontal and vertical direction that will be addressed. (Possible values: 16, 32, 48, 64. Server default: 16)
1315
* @param value Possible values: 16, 32, 48, 64. Server default: 16.
1416
*/
1517
shakeStrength(value: 16 | 32 | 48 | 64 | string | ExpressionQualifier): this {
16-
return this.setLevel(value);
18+
this._actionModel.pixels = value as number;
19+
const qualifierEffect = this.createEffectQualifier(this.effectType, value);
20+
this.addQualifier(qualifierEffect);
21+
return this;
1722
}
1823
}
1924

src/internal/models/IEffectActionModel.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ interface ISimulateColorBlindEffectModel extends IActionModel{
6464
condition?: string;
6565
}
6666

67+
interface IDeshakeEffectModel extends IActionModel{
68+
pixels?: number;
69+
}
70+
6771
export {
6872
IEffectActionWithLevelModel,
6973
ISimpleEffectActionModel,
@@ -76,5 +80,6 @@ export {
7680
IVectorizeEffectModel,
7781
IGradientFadeEffecModel,
7882
IAssistColorBlindEffectModel,
79-
ISimulateColorBlindEffectModel
83+
ISimulateColorBlindEffectModel,
84+
IDeshakeEffectModel
8085
};

0 commit comments

Comments
 (0)