Skip to content

Commit

Permalink
fix: fix for function property value (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Mar 10, 2019
1 parent 6f0a211 commit 838f532
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"doc": "rm -rf ./doc && jsdoc -c jsdoc.json",
"demo:start": "demo demo.js -w",
"demo:build": "rm -rf ./demo/dist && demo demo.js",
"release": "npm run build && npm run release:build && npm run deploy",
"release": "npm run build && npm run demo:build && npm run release:build && npm run deploy",
"release:build": "npm run release:mkdir && npm run doc && npm run release:version && npm run release:latest",
"release:mkdir": "mkdir -p ./demo/release && rm -rf ./demo/release/$npm_package_version && rm -rf ./demo/release/latest && mkdir -p ./demo/release/$npm_package_version && mkdir -p ./demo/release/latest",
"release:version": "cp -a ./dist/. ./demo/release/$npm_package_version/dist && cp -a ./doc/. ./demo/release/$npm_package_version/doc && cp -a ./examples/. ./demo/release/$npm_package_version/examples",
Expand Down
2 changes: 1 addition & 1 deletion src/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function merge(to: IObject<any>, from: IObject<any>, toValue = false) {
if (type === PROPERTY) {
to[name] = toValue ? value.toValue() : value.clone();
} else if (type === FUNCTION) {
to[name] = toValue ? getValue([name], value()) : value;
to[name] = toValue ? getValue([name], value) : value;
} else if (type === ARRAY) {
to[name] = value.slice();
} else if (type === OBJECT) {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Frame from "./Frame";
import Animator from "./Animator";

export { SceneItem, Frame, Animator };
export { bezier, EASE_IN_OUT, EASE_IN, EASE_OUT, EASE, LINEAR, steps, STEP_START, STEP_END } from "./easing";
export { transition, wipeIn, wipeOut, fadeIn, fadeOut, blink, zoomIn, zoomOut, animate} from "./presets";
export * from "./easing";
export * from "./presets";
export { OPTIONS, EVENTS } from "./consts";
export { setRole, setAlias } from "./utils";
export { Scene as default };
21 changes: 21 additions & 0 deletions test/unit/Frame.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Frame from "../../src/Frame";
import {setAlias} from "../../src/utils";
import { EASE_IN_OUT } from "../../src/easing";
import { TIMING_FUNCTION, EASING_NAME } from "../../src/consts";

describe("Frame Test", () => {
describe("test frame initialize", () => {
Expand Down Expand Up @@ -190,6 +192,25 @@ describe("Frame Test", () => {
},
});
});
it("should check 'toCSSObject' method", () => {
frame = new Frame({
a: 1,
b: 2,
transform: "scale(1, 2) translateX(100px) translateY(200px)",
filter: {
brightness: "90%",
grayscale: "40%",
},
easing: EASE_IN_OUT,
});
const obj = frame.toCSSObject();

expect(obj.a).to.be.equals(1);
expect(obj.b).to.be.equals(2);
expect(obj.transform).to.be.equals("scale(1,2) translateX(100px) translateY(200px)");
expect(obj.filter).to.be.equals("brightness(90%) grayscale(40%)");
expect(obj[TIMING_FUNCTION]).to.be.equals(EASE_IN_OUT[EASING_NAME]);
});
it("should check 'toCSS' method", () => {
const css = frame.toCSS().replace(/;(\S)/g, ";\n$1").split("\n");

Expand Down

0 comments on commit 838f532

Please sign in to comment.