Skip to content

Commit

Permalink
fixed frame.js
Browse files Browse the repository at this point in the history
lib/main.js -> ./index.js
require the new things like prime 0.1 and elements 0.1
updated frame tests
updated all paths
minor version bump
  • Loading branch information
kamicane committed Jan 22, 2013
1 parent 78efea7 commit dccbebf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 31 deletions.
8 changes: 0 additions & 8 deletions .npmignore
@@ -1,11 +1,3 @@
.gitmodules
.gitignore
.DS_Store
*.html
makejs
src/*
test/*
moofx.js
moofx-min.js
.tm_properties
test.js
6 changes: 0 additions & 6 deletions distribute
Expand Up @@ -27,12 +27,6 @@ var wrupit = function(){

wrup.options({output: "./moofx.js", watch: args.indexOf("--watch") > -1, compress: true})

wrup.exclude("array.isArray", "array.every", "array.some", "array.filter",
"string.contains", "string.number", "string.escape", "string.decode",
"fixEnumBug")

if (args.indexOf("--css3") > -1) wrup.exclude("css3")

wrup.require("moofx", "./")

wrup.on("end", function(js){
Expand Down
6 changes: 3 additions & 3 deletions lib/main.js → index.js
Expand Up @@ -4,11 +4,11 @@
*/"use strict"

// color and timer
var color = require("./color"),
frame = require("./frame")
var color = require("./lib/color"),
frame = require("./lib/frame")

// if we're in a browser we need ./browser, otherwise ./fx
var moofx = (typeof document !== "undefined") ? require("./browser") : require("./fx")
var moofx = (typeof document !== "undefined") ? require("./lib/browser") : require("./lib/fx")

moofx.requestFrame = function(callback){
frame.request(callback)
Expand Down
6 changes: 3 additions & 3 deletions lib/browser.js
Expand Up @@ -10,9 +10,9 @@ var color = require("./color"),
var cancelFrame = frame.cancel,
requestFrame = frame.request

var prime = require("prime/prime/"),
var prime = require("prime"),
array = require("prime/es5/array"),
string = require("prime/types/string")
string = require("prime/shell/string")

var camelize = string.camelize,
clean = string.clean,
Expand All @@ -22,7 +22,7 @@ var map = array.map,
forEach = array.forEach,
indexOf = array.indexOf

var elements = require("elements/lib/elements")
var elements = require("elements")

var fx = require("./fx")

Expand Down
4 changes: 2 additions & 2 deletions lib/frame.js
Expand Up @@ -16,8 +16,8 @@ var requestFrame = global.requestAnimationFrame ||
var callbacks = []

var iterator = function(time){
var callback
while ((callback = callbacks.shift())) callback(time || (time = +(new Date)))
var split = callbacks.splice(0)
for (var i = 0, l = split.length; i < l; i++) split[i](time || (time = +(new Date)))
}

var cancel = function(callback){
Expand Down
2 changes: 1 addition & 1 deletion lib/fx.js
Expand Up @@ -2,7 +2,7 @@
fx
*/"use strict"

var prime = require("prime/prime/"),
var prime = require("prime"),
requestFrame = require("./frame").request,
bezier = require("cubic-bezier")

Expand Down
8 changes: 4 additions & 4 deletions package.json
@@ -1,9 +1,9 @@
{
"name": "moofx",
"description": "A CSS3-enabled javascript animation library for node and the browser",
"version": "3.0.14-dev",
"version": "3.1.0-dev",
"license": "MIT (http://mootools.net/license.txt)",
"main": "./lib/main.js",
"main": "./index.js",
"keywords": [
"moofx",
"fx",
Expand All @@ -22,8 +22,8 @@
},
"dependencies": {
"cubic-bezier": "0.1.2",
"prime": "0.0.6",
"elements": "0.0.9"
"prime": "0.1",
"elements": "0.1"
},
"sources": [
"./moofx.js"
Expand Down
16 changes: 12 additions & 4 deletions test/test.frame.js
Expand Up @@ -72,29 +72,37 @@ describe('requestFrame/cancelFrame', function (){

})

it('should not have a race condition :~)', function(done){
it('should only be able to cancel frames that are not part of the current iteration.', function(done){

var nextCalled = false
var next2Called = false
var next3Called = false

var next = function(now){
nextCalled = true
moofx.cancelFrame(next2)
moofx.cancelFrame(next2) // this should do nothing
moofx.requestFrame(next3)
}

var next2 = function(now){
next2Called = true
moofx.cancelFrame(next3) // this should cancel the third, as it is not part of the current iteration
}

var next3 = function(){
next3Called = true
}

var doneFrame = function(){
expect(nextCalled).to.be(true)
expect(next2Called).to.be(false)
expect(next2Called).to.be(true)
expect(next3Called).to.be(false)
done()
}

moofx.requestFrame(next)
moofx.requestFrame(next2)
moofx.requestFrame(next3)
moofx.requestFrame(doneFrame)

})

Expand Down

0 comments on commit dccbebf

Please sign in to comment.