Skip to content

Instantly share code, notes, and snippets.

@Jeremboo
Created October 3, 2018 02:11
Show Gist options
  • Save Jeremboo/15620283d93f51d914746232c5d14c77 to your computer and use it in GitHub Desktop.
Save Jeremboo/15620283d93f51d914746232c5d14c77 to your computer and use it in GitHub Desktop.
Stock and distribute animations
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