Created
October 3, 2018 02:11
-
-
Save Jeremboo/15620283d93f51d914746232c5d14c77 to your computer and use it in GitHub Desktop.
Stock and distribute animations
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
class AnimationManager { | |
constructor () { | |
this.animMap = new Map() | |
// To manage the status of the menu during the transition | |
// and lock clicks. | |
this.menuInTransition = false | |
} | |
save (animName, tweenAnim) { | |
this.animMap.set(animName, tweenAnim) | |
} | |
delete (animName) { | |
this.animMap.delete(animName) | |
} | |
get (animName, callback) { | |
const anim = this.animMap.get(animName) | |
if (typeof (anim) !== 'function') { | |
console.log(`ERROR.getAnimation(): ${animName} doesn't exist`) | |
return undefined | |
} | |
const tween = anim(callback) | |
return tween | |
} | |
} | |
const am = new AnimationManager() | |
export default am |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment