From 336a65f31a4d83ee196cc9bf95100cc4d6552a0f Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 28 Jul 2019 04:40:17 +0000 Subject: [PATCH] assets/scripts.js: Pause and unpause on click - By placing the event handler on the video element, we ensure we don't receive it when a choice item was clicked. - Use preventDefault to avoid the pause-and-immediately-unpause problem due to the video element itself also handling the event. --- assets/scripts.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/assets/scripts.js b/assets/scripts.js index dec8f84..2e4906e 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -398,12 +398,9 @@ window.onload = function() { var c = document.getElementById("c"); c.ondblclick = toggleFullScreen; - c.onclick = function () { - // can't togglePlayPause here, choice buttons stop the video - // should use preventdefault or something - // use spacebar for now - // mind that autoplay is disabled in latest chrome, so play after click - document.getElementById("video").play(); + video_selector.onclick = function (e) { + togglePlayPause(); + e.preventDefault(); }; document.onkeypress = function (e) {