forked from bhovhannes/additween
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5209de5
commit 1472b42
Showing
8 changed files
with
170 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
AdditiveTweeningMock: require('./src/AdditiveTweeningMock') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict' | ||
|
||
function noop() {} | ||
|
||
function AdditiveTweeningMock() { | ||
|
||
this.originalMethods = { | ||
scheduleAnimationFrame: undefined, | ||
now: undefined | ||
} | ||
this.reset() | ||
} | ||
|
||
AdditiveTweeningMock.prototype.tick = function(duration) { | ||
this.time += duration | ||
if (this.animationStepScheduled) { | ||
this.animationStep() | ||
this.animationStepScheduled = false | ||
} | ||
} | ||
|
||
AdditiveTweeningMock.prototype.reset = function() { | ||
this.time = 0 | ||
this.animationStep = noop | ||
this.animationStepScheduled = false | ||
} | ||
|
||
AdditiveTweeningMock.prototype.stubs = { | ||
scheduleAnimationFrame: function(cb) { | ||
this.animationStep = cb | ||
this.animationStepScheduled = true | ||
}, | ||
|
||
now: function() { | ||
return this.time | ||
} | ||
} | ||
|
||
AdditiveTweeningMock.prototype.install = function(additiveTweening) { | ||
for (var key in this.originalMethods) { | ||
this.originalMethods[key] = additiveTweening.prototype[key] | ||
additiveTweening.prototype[key] = this.stubs[key].bind(this) | ||
} | ||
this.reset() | ||
} | ||
|
||
AdditiveTweeningMock.prototype.uninstall = function(additiveTweening) { | ||
for (var key in this.originalMethods) { | ||
additiveTweening.prototype[key] = this.originalMethods[key] | ||
} | ||
this.reset() | ||
} | ||
|
||
|
||
module.exports = AdditiveTweeningMock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters