Skip to content

Commit

Permalink
Fixed js error when click the page (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang authored and chrisvfritz committed Jan 26, 2018
1 parent e6ac092 commit 01aed53
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion themes/vue/source/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,24 @@
var player = new Vimeo.Player(iframe)
var overlay = document.createElement('div')
overlay.className = 'overlay'
var isOpen = false

modalButton.addEventListener('click', function(event) {
event.stopPropagation()
videoModal.classList.toggle('open')
document.body.classList.toggle('stop-scroll')
document.body.appendChild(overlay)
player.play()
isOpen = true
})

document.body.addEventListener('click', function(e) {
if (e.target !== modalButton && !videoModal.contains(e.target)) {
if (isOpen && e.target !== modalButton && !videoModal.contains(e.target)) {
videoModal.classList.remove('open')
document.body.classList.remove('stop-scroll')
document.body.removeChild(overlay)
player.unload()
isOpen = false
}
})
}
Expand Down

0 comments on commit 01aed53

Please sign in to comment.