Skip to content

Commit

Permalink
🐛 fix: fix array properties
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Jun 20, 2019
1 parent e1f0c24 commit 6dfe914
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SceneItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class SceneItem extends Animator<SceneItemOptions, SceneItemState> {
const length = arr.length;

for (let i = 0; i < length; ++i) {
this.newFrame(`${i / (length - 1) * 100}%`).set(names, arr[i]);
this.newFrame(`${i / (length - 1) * 100}%`).set(...names, arr[i]);
}
});
} else {
Expand Down
28 changes: 28 additions & 0 deletions test/unit/SceneItem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,34 @@ describe("SceneItem Test", () => {
expect(item.get(1 / 3, "opacity")).to.be.equals("0.5");
expect(item.get(1 + 2, "opacity")).to.be.equals("1");
});
it("should check array property", () => {
// Given, When
const item = new SceneItem({
opacity: [0, 1],
});
const item2 = new SceneItem({
transform: {
translate: ["0px", "20px"],
},
});
const item3 = new SceneItem({
transform: [
"translate(0px)",
"translate(20px)",
],
});

// Then
expect(item.getDuration()).to.be.equals(100);
expect(item.get(0, "opacity")).to.be.equals(0);
expect(item.get("100%", "opacity")).to.be.equals(1);

expect(item2.get(0, "transform", "translate")).to.be.equals("0px");
expect(item2.get("100%", "transform", "translate")).to.be.equals("20px");

expect(item3.get(0, "transform", "translate")).to.be.equals("0px");
expect(item3.get("100%", "transform", "translate")).to.be.equals("20px");
});
it("should check multiple time", () => {
// Given, When
const item = new SceneItem({
Expand Down

0 comments on commit 6dfe914

Please sign in to comment.