Skip to content

Commit

Permalink
move defaultTween
Browse files Browse the repository at this point in the history
  • Loading branch information
ded committed Dec 10, 2012
1 parent 1a0f377 commit 8d4bf7d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
16 changes: 9 additions & 7 deletions morpheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

// convert rgb and short hex to long hex
function toHex(c) {
var m = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(c)
var m = c.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/)
return (m ? rgb(m[1], m[2], m[3]) : c)
.replace(/#(\w)(\w)(\w)$/, '#$1$1$2$2$3$3') // short skirt to long jacket
}
Expand All @@ -162,6 +162,11 @@
return typeof f == 'function'
}

function nativeTween(t) {
// default to a pleasant-to-the-eye easeOut (like native animations)
return Math.sin(t * Math.PI / 2)
}

/**
* Core tween method that requests each frame
* @param duration: time in milliseconds. defaults to 1000
Expand All @@ -173,10 +178,7 @@
* @returns method to stop the animation
*/
function tween(duration, fn, done, ease, from, to) {
ease = fun(ease) ? ease : morpheus.easings[ease] || function (t) {
// default to a pleasant-to-the-eye easeOut (like native animations)
return Math.sin(t * Math.PI / 2)
}
ease = fun(ease) ? ease : morpheus.easings[ease] || nativeTween
var time = duration || thousand
, self = this
, diff = to - from
Expand All @@ -198,9 +200,9 @@
fn((diff * ease(delta / time)) + from) :
fn(ease(delta / time))
}

live(run)

return {
stop: function (jump) {
stop = 1
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.

16 changes: 9 additions & 7 deletions src/morpheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

// convert rgb and short hex to long hex
function toHex(c) {
var m = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(c)
var m = c.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/)
return (m ? rgb(m[1], m[2], m[3]) : c)
.replace(/#(\w)(\w)(\w)$/, '#$1$1$2$2$3$3') // short skirt to long jacket
}
Expand All @@ -157,6 +157,11 @@
return typeof f == 'function'
}

function nativeTween(t) {
// default to a pleasant-to-the-eye easeOut (like native animations)
return Math.sin(t * Math.PI / 2)
}

/**
* Core tween method that requests each frame
* @param duration: time in milliseconds. defaults to 1000
Expand All @@ -168,10 +173,7 @@
* @returns method to stop the animation
*/
function tween(duration, fn, done, ease, from, to) {
ease = fun(ease) ? ease : morpheus.easings[ease] || function (t) {
// default to a pleasant-to-the-eye easeOut (like native animations)
return Math.sin(t * Math.PI / 2)
}
ease = fun(ease) ? ease : morpheus.easings[ease] || nativeTween
var time = duration || thousand
, self = this
, diff = to - from
Expand All @@ -193,9 +195,9 @@
fn((diff * ease(delta / time)) + from) :
fn(ease(delta / time))
}

live(run)

return {
stop: function (jump) {
stop = 1
Expand Down

0 comments on commit 8d4bf7d

Please sign in to comment.