From 01aed53db61b7fa2c9f24fcdd9ee9049a8bede8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8B=BE=E4=B8=89=E8=82=A1=E5=9B=9B?= Date: Sat, 27 Jan 2018 05:40:17 +0800 Subject: [PATCH] Fixed js error when click the page (#1401) --- themes/vue/source/js/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/vue/source/js/common.js b/themes/vue/source/js/common.js index 91d12ff8f7..c2ab9e794b 100644 --- a/themes/vue/source/js/common.js +++ b/themes/vue/source/js/common.js @@ -155,6 +155,7 @@ var player = new Vimeo.Player(iframe) var overlay = document.createElement('div') overlay.className = 'overlay' + var isOpen = false modalButton.addEventListener('click', function(event) { event.stopPropagation() @@ -162,14 +163,16 @@ 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 } }) }