Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to previous RAF shim, support window.performance.now() #36

Merged
merged 2 commits into from
Dec 5, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"node": true,
"asi": true,
"laxcomma": true,
"boss": true,
"browser": true,
"eqnull": true,
"expr": true,
"loopfunc": true,
"strict": false,
"trailing": true,
"undef": true,
"smarttabs": true,
"supernew": true,
"sub": true,
"predef": ["define", "require"]
}
28 changes: 10 additions & 18 deletions morpheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var context = this
, doc = document
, win = window
, perf = win.performance
, html = doc.documentElement
, thousand = 1000
, rgbOhex = /^rgb\(|#/
Expand All @@ -24,7 +25,7 @@
// these elements do not require 'px'
, unitless = { lineHeight: 1, zoom: 1, zIndex: 1, opacity: 1, transform: 1}

// which property name does this browser use for transform
// which property name does this browser use for transform
var transform = function () {
var styles = doc.createElement('a').style
, props = ['webkitTransform', 'MozTransform', 'OTransform', 'msTransform', 'Transform']
Expand All @@ -34,12 +35,12 @@
}
}()

// does this browser support the opacity property?
// does this browser support the opacity property?
var opasity = function () {
return typeof doc.createElement('a').style.opacity !== 'undefined'
}()

// initial style is determined by the elements themselves
// initial style is determined by the elements themselves
var getStyle = doc.defaultView && doc.defaultView.getComputedStyle ?
function (el, property) {
property = property == 'transform' ? transform : property
Expand Down Expand Up @@ -74,25 +75,16 @@
// native animation frames
// http://webstuff.nfshost.com/anim-timing/Overview.html
// http://dev.chromium.org/developers/design-documents/requestanimationframe-implementation

var animationFrame = win.requestAnimationFrame ||
win.mozRequestAnimationFrame ||
return win.requestAnimationFrame ||
win.webkitRequestAnimationFrame ||
win.msRequestAnimationFrame ||
win.oRequestAnimationFrame ||
undefined

if (animationFrame === undefined) {
return function (callback) {
win.mozRequestAnimationFrame ||
win.msRequestAnimationFrame ||
win.oRequestAnimationFrame ||
function (callback) {
win.setTimeout(function () {
callback(+new Date())
}, 11) // these go to eleven
}
} else {
return function (callback) {
animationFrame(function () { callback(+new Date()) })
}
}
}()

var children = []
Expand Down Expand Up @@ -184,7 +176,7 @@
var time = duration || thousand
, self = this
, diff = to - from
, start = +new Date()
, start = perf && perf.now ? perf.now() : +new Date()
, stop = 0
, end = 0
live(run)
Expand Down
2 changes: 1 addition & 1 deletion morpheus.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 10 additions & 18 deletions src/morpheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var context = this
, doc = document
, win = window
, perf = win.performance
, html = doc.documentElement
, thousand = 1000
, rgbOhex = /^rgb\(|#/
Expand All @@ -19,7 +20,7 @@
// these elements do not require 'px'
, unitless = { lineHeight: 1, zoom: 1, zIndex: 1, opacity: 1, transform: 1}

// which property name does this browser use for transform
// which property name does this browser use for transform
var transform = function () {
var styles = doc.createElement('a').style
, props = ['webkitTransform', 'MozTransform', 'OTransform', 'msTransform', 'Transform']
Expand All @@ -29,12 +30,12 @@
}
}()

// does this browser support the opacity property?
// does this browser support the opacity property?
var opasity = function () {
return typeof doc.createElement('a').style.opacity !== 'undefined'
}()

// initial style is determined by the elements themselves
// initial style is determined by the elements themselves
var getStyle = doc.defaultView && doc.defaultView.getComputedStyle ?
function (el, property) {
property = property == 'transform' ? transform : property
Expand Down Expand Up @@ -69,25 +70,16 @@
// native animation frames
// http://webstuff.nfshost.com/anim-timing/Overview.html
// http://dev.chromium.org/developers/design-documents/requestanimationframe-implementation

var animationFrame = win.requestAnimationFrame ||
win.mozRequestAnimationFrame ||
return win.requestAnimationFrame ||
win.webkitRequestAnimationFrame ||
win.msRequestAnimationFrame ||
win.oRequestAnimationFrame ||
undefined

if (animationFrame === undefined) {
return function (callback) {
win.mozRequestAnimationFrame ||
win.msRequestAnimationFrame ||
win.oRequestAnimationFrame ||
function (callback) {
win.setTimeout(function () {
callback(+new Date())
}, 11) // these go to eleven
}
} else {
return function (callback) {
animationFrame(function () { callback(+new Date()) })
}
}
}()

var children = []
Expand Down Expand Up @@ -179,7 +171,7 @@
var time = duration || thousand
, self = this
, diff = to - from
, start = +new Date()
, start = perf && perf.now ? perf.now() : +new Date()
, stop = 0
, end = 0
live(run)
Expand Down