UNPKG

mdx-m3-viewer

Version:

A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.

25 lines (20 loc) 576 B
class Toggle extends Component { constructor(offName, onName, callback, options) { super({ ...options, tagName: 'button', textContent: offName, onclick: () => this.toggle() }); this.offName = offName; this.onName = onName; this.callback = callback; this.clicked = false; } toggle() { this.clicked = !this.clicked; if (this.clicked) { this.container.textContent = this.onName; } else { this.container.textContent = this.offName; } if (this.callback) { this.callback(this); } } }