Skip to content

Commit

Permalink
fix(ellipse): added missing property Direction
Browse files Browse the repository at this point in the history
  • Loading branch information
thoaif committed Aug 18, 2021
1 parent d8f1620 commit 58bc619
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/shapes/ellipse-shape.test.ts
@@ -0,0 +1,27 @@
import { EllipseShape } from './ellipse-shape';

describe('Test EllipseShape', () => {
test(`fromJSON() is equal to toJSON()?`, async () => {
const ellipse = new EllipseShape(null);
const shapeDef = {
nm: 'Ellipse',
mn: 'Ellipses',
hd: false,
d: 1,
ty: 'el',
s: {
a: 0,
k: [42, 42],
ix: 2,
},
p: {
a: 0,
k: [0, 0],
ix: 3,
},
};

ellipse.fromJSON(shapeDef);
expect(JSON.parse(JSON.stringify(ellipse))).toEqual(shapeDef);
});
});
4 changes: 4 additions & 0 deletions src/shapes/ellipse-shape.ts
Expand Up @@ -15,6 +15,8 @@ export class EllipseShape extends Shape {

public size: Property = new Property(this, PropertyType.SIZE);

public direction = 1;

/**
* Convert the Lottie JSON object to class instance.
*
Expand All @@ -32,6 +34,7 @@ export class EllipseShape extends Shape {
// This shape
this.position.fromJSON(json.p);
this.size.fromJSON(json.s);
this.direction = json.d;

return this;
}
Expand All @@ -57,6 +60,7 @@ export class EllipseShape extends Shape {
// This shape
p: this.position,
s: this.size,
d: this.direction,
};
}
}

0 comments on commit 58bc619

Please sign in to comment.