Skip to content

Commit

Permalink
Allow adding multiple space-separated classes for openClass
Browse files Browse the repository at this point in the history
  • Loading branch information
liamtarpey committed Oct 21, 2020
1 parent 4d03e7e commit a7e9e58
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ const MicroModal = (() => {
}

showModal (event = null) {
const openClass = this.config.openClass.split(' ')
this.activeElement = document.activeElement
this.modal.setAttribute('aria-hidden', 'false')
this.modal.classList.add(this.config.openClass)
this.modal.classList.add(...openClass)
this.scrollBehaviour('disable')
this.addEventListeners()

Expand All @@ -85,14 +86,14 @@ const MicroModal = (() => {
}
this.config.onClose(this.modal, this.activeElement, event)

let openClass = this.config.openClass.split(' ') // <- old school ftw
if (this.config.awaitCloseAnimation) {
let openClass = this.config.openClass // <- old school ftw
this.modal.addEventListener('animationend', function handler () {
modal.classList.remove(openClass)
modal.classList.remove(...openClass)
modal.removeEventListener('animationend', handler, false)
}, false)
} else {
modal.classList.remove(this.config.openClass)
modal.classList.remove(...openClass)
}
}

Expand Down

0 comments on commit a7e9e58

Please sign in to comment.