-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert Style and related classes to ES6 class syntax
- Loading branch information
Showing
7 changed files
with
321 additions
and
311 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
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 |
---|---|---|
@@ -1,30 +1,32 @@ | ||
'use strict'; | ||
|
||
module.exports = AnimationLoop; | ||
class AnimationLoop { | ||
constructor() { | ||
this.n = 0; | ||
this.times = []; | ||
} | ||
|
||
function AnimationLoop() { | ||
this.n = 0; | ||
this.times = []; | ||
} | ||
// Are all animations done? | ||
stopped() { | ||
this.times = this.times.filter((t) => { | ||
return t.time >= (new Date()).getTime(); | ||
}); | ||
return !this.times.length; | ||
} | ||
|
||
// Are all animations done? | ||
AnimationLoop.prototype.stopped = function() { | ||
this.times = this.times.filter((t) => { | ||
return t.time >= (new Date()).getTime(); | ||
}); | ||
return !this.times.length; | ||
}; | ||
// Add a new animation that will run t milliseconds | ||
// Returns an id that can be used to cancel it layer | ||
set(t) { | ||
this.times.push({ id: this.n, time: t + (new Date()).getTime() }); | ||
return this.n++; | ||
} | ||
|
||
// Add a new animation that will run t milliseconds | ||
// Returns an id that can be used to cancel it layer | ||
AnimationLoop.prototype.set = function(t) { | ||
this.times.push({ id: this.n, time: t + (new Date()).getTime() }); | ||
return this.n++; | ||
}; | ||
// Cancel an animation | ||
cancel(n) { | ||
this.times = this.times.filter((t) => { | ||
return t.id !== n; | ||
}); | ||
} | ||
} | ||
|
||
// Cancel an animation | ||
AnimationLoop.prototype.cancel = function(n) { | ||
this.times = this.times.filter((t) => { | ||
return t.id !== n; | ||
}); | ||
}; | ||
module.exports = AnimationLoop; |
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
Oops, something went wrong.