Created
January 3, 2016 19:47
-
-
Save ynonp/176b06a8298ce8c48b5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var el = document.querySelector('main'); | |
let g1 = new Game(); | |
let g2 = new Game(); | |
let g3 = new Game(); | |
let layout = new StackLayout(el); | |
layout.addItem('g1', g1); | |
layout.addItem('g2', g2); | |
layout.addItem('g3', g3); |
This file contains hidden or 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
export default class StackLayout { | |
constructor(el) { | |
this.el = el; | |
this.items = {}; | |
} | |
setActiveItem(itemId) { | |
this.items[itemId].render(this.el); | |
} | |
addItem(id, item) { | |
this.items[id] = item; | |
} | |
getItemIds() { | |
return Object.keys(this.items); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment