Permalink
Browse files

signature for fx is now fx(fn).start(from, to, options)

like the browser counterpart
if it starts with two arrays, will result in array; if it starts with two numbers, will result in a number
options for basefx accepts callback function or duration string / number
  • Loading branch information...
1 parent dc1ad8c commit 38b089cbb80d706be43792b253c9dd4212f01a49 @kamicane kamicane committed Apr 14, 2012
Showing with 24 additions and 8 deletions.
  1. +1 −2 lib/browser.js
  2. +22 −5 lib/fx.js
  3. +1 −1 makejs
View
@@ -822,8 +822,7 @@ var BaseAnimation = transitionName ? CSSAnimation : JSAnimation
//var BaseAnimation = JSAnimation
var moofx = function(x, y){
- if (typeof x === "function") return fx(x, y)
- return nodes(x, y)
+ return (typeof x === "function") ? fx(x) : nodes(x, y)
}
nodes.implement({
View
@@ -127,6 +127,18 @@ var Fx = prime({
return this
}
+ this.isArray = false
+ this.isNumber = false
+
+ var fromType = typeof from,
+ toType = typeof to
+
+ if (fromType === "object" && toType === "object"){
+ this.isArray = true
+ } else if (fromType === "number" && toType === "number"){
+ this.isNumber = true
+ }
+
var from_ = divide(from),
to_ = divide(to)
@@ -179,7 +191,7 @@ var Fx = prime({
tpl = tpl.replace("@", t !== f ? compute(f, t, delta) : t)
}
- this.render(tpl)
+ this.render(this.isArray ? tpl.split(",") : this.isNumber ? +tpl : tpl)
if (factor !== 1){
this.cancelStep = requestFrame(this.bStep)
@@ -192,14 +204,19 @@ var Fx = prime({
})
-var fx = function(render, options){
+var fx = function(render){
- var ffx = new Fx(render, options)
+ var ffx = new Fx(render)
return {
- start: function(from, to){
- ffx.start(from, to)
+ start: function(from, to, options){
+ var type = typeof options
+ ffx.setOptions((type === "function") ? {
+ callback: options
+ } : (type === "string" || type === "number") ? {
+ duration: options
+ } : options).start(from, to)
return this
},
View
@@ -48,7 +48,7 @@ if (a2 === '--watch' || a2 === '-w'){
console.log(" watching...\n")
- var scripts = ['./lib/main.js', './lib/color.js', './lib/frame.js', './lib/browser.js', './lib/unmatrix2d.js']
+ var scripts = ['./lib/main.js', './lib/color.js', './lib/frame.js', './lib/fx.js', './lib/unmatrix2d.js', './lib/browser.js']
scripts.forEach(function(script){
var filedata = fs.readFileSync(script, "utf-8")

0 comments on commit 38b089c

Please sign in to comment.