Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created January 3, 2016 19:47
Show Gist options
  • Save ynonp/176b06a8298ce8c48b5b to your computer and use it in GitHub Desktop.
Save ynonp/176b06a8298ce8c48b5b to your computer and use it in GitHub Desktop.
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);
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