Skip to content

Commit

Permalink
fix: set frame for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Jun 18, 2019
1 parent ff7e550 commit 2b2f978
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 5 additions & 6 deletions src/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ class Frame {
const params = args.slice(0, -1);
const value = args[length - 1];
const firstParam = params[0];
if (firstParam instanceof Frame) {
self.merge(firstParam);

if (length === 1 && value instanceof Frame) {
self.merge(value);
} else if (firstParam in ALIAS) {
self._set(ALIAS[firstParam], value);
} else if (length === 2 && isArray(firstParam)) {
Expand Down Expand Up @@ -262,11 +263,9 @@ class Frame {
const properties = this.properties;
const frameProperties = frame.properties;

if (!frameProperties) {
return this;
if (frameProperties) {
merge(properties, frameProperties);
}
merge(properties, frameProperties);

return this;
}
/**
Expand Down
8 changes: 4 additions & 4 deletions src/SceneItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ class SceneItem extends Animator<SceneItemOptions, SceneItemState> {
console.log(item.get(0, "a")); // "b"
*/
public set(time: any, ...args: any[]) {
if (isArray(time)) {
if (time instanceof SceneItem) {
return this.set(0, time);
} else if (isArray(time)) {
const length = time.length;

for (let i = 0; i < length; ++i) {
Expand Down Expand Up @@ -272,9 +274,7 @@ class SceneItem extends Animator<SceneItemOptions, SceneItemState> {
} else {
const value = args[0];

if (value instanceof Frame) {
this.setFrame(time, value);
} else if (value instanceof SceneItem) {
if (value instanceof SceneItem) {
const delay = value.getDelay();
const realTime = this.getUnitTime(time);
const frames = value.toObject(!this.hasFrame(realTime + delay));
Expand Down
3 changes: 2 additions & 1 deletion test/unit/SceneItem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ describe("SceneItem Test", () => {
expect(frame.get("html3", "c")).to.be.deep.equals(4);
});
it(`should check 'append' method`, () => {
// 1 3 2
this.item.append(new SceneItem({
0: {
a: 3,
Expand Down Expand Up @@ -1046,6 +1047,6 @@ describe("SceneItem Test", () => {
expect(html2).to.be.equals("1");
expect(html3).to.be.equals("2");
expect(html4).to.be.equals("3");
})
});
});
});

0 comments on commit 2b2f978

Please sign in to comment.