Skip to content

Commit

Permalink
Merge pull request ded#18 from eleith/master
Browse files Browse the repository at this point in the history
providing 'this' context to animation callbacks on 'complete'
  • Loading branch information
ded committed Nov 28, 2011
2 parents a2c64ec + f3abc69 commit 15bb0c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions morpheus.js
Expand Up @@ -139,6 +139,7 @@
return Math.sin(t * Math.PI / 2)
}
var time = duration || 1000
, self = this
, diff = to - from
, start = +new Date()
, stop = 0
Expand All @@ -150,7 +151,7 @@
if (delta > time || stop) {
to = isFinite(to) ? to : 1
stop ? end && fn(to) : fn(to)
return done && done()
return done && done.apply(self)
}
// if you don't specify a 'to' you can use tween as a generic delta tweener
// cool, eh?
Expand Down Expand Up @@ -320,7 +321,7 @@
}
}
// ONE TWEEN TO RULE THEM ALL
return tween(duration, function (pos, v, xy) {
return tween.apply(els, [duration, function (pos, v, xy) {
// normally not a fan of optimizing for() loops, but we want something
// fast for animating
for (i = els.length; i--;) {
Expand All @@ -338,7 +339,7 @@
(els[i].style[camelize(k)] = v)
}
}
}, complete, ease)
}, complete, ease])
}

// expose useful methods
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.

7 changes: 4 additions & 3 deletions src/morpheus.js
Expand Up @@ -134,6 +134,7 @@
return Math.sin(t * Math.PI / 2)
}
var time = duration || 1000
, self = this
, diff = to - from
, start = +new Date()
, stop = 0
Expand All @@ -145,7 +146,7 @@
if (delta > time || stop) {
to = isFinite(to) ? to : 1
stop ? end && fn(to) : fn(to)
return done && done()
return done && done.apply(self)
}
// if you don't specify a 'to' you can use tween as a generic delta tweener
// cool, eh?
Expand Down Expand Up @@ -315,7 +316,7 @@
}
}
// ONE TWEEN TO RULE THEM ALL
return tween(duration, function (pos, v, xy) {
return tween.apply(els, [duration, function (pos, v, xy) {
// normally not a fan of optimizing for() loops, but we want something
// fast for animating
for (i = els.length; i--;) {
Expand All @@ -333,7 +334,7 @@
(els[i].style[camelize(k)] = v)
}
}
}, complete, ease)
}, complete, ease])
}

// expose useful methods
Expand Down

0 comments on commit 15bb0c0

Please sign in to comment.