Browse Source

Window: Add a 'visible' property (to avoid re-showing closed windows)

master
parent
commit
867f8b6fc6
  1. 5
      src/Window.js

5
src/Window.js

@ -4,6 +4,7 @@ module.exports = class Window extends EventEmitter {
constructor (options) { constructor (options) {
super() super()
this.visible = false
this.dom = document.createElement('div') this.dom = document.createElement('div')
this.dom.className = 'Window' this.dom.className = 'Window'
@ -27,6 +28,8 @@ module.exports = class Window extends EventEmitter {
dragElement(this.dom) dragElement(this.dom)
this.dom.onclick = () => { this.dom.onclick = () => {
if (!this.visible) { return }
const activeEl = document.activeElement const activeEl = document.activeElement
if (document.body.lastElementChild !== this.dom) { if (document.body.lastElementChild !== this.dom) {
@ -37,11 +40,13 @@ module.exports = class Window extends EventEmitter {
} }
show () { show () {
this.visible = true
document.body.appendChild(this.dom) document.body.appendChild(this.dom)
this.emit('show') this.emit('show')
} }
close () { close () {
this.visible = false
document.body.removeChild(this.dom) document.body.removeChild(this.dom)
this.emit('close') this.emit('close')
} }

Loading…
Cancel
Save