From bfcb6eac4171957f681b39cddd1abbb64a177b9b Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 3 Sep 2025 19:37:24 +0000 Subject: [PATCH] fix chrome reverting video pause toggles pausing a video with spacebar while video is focused would first get handled by the js hotkey, and then chrome would ignore our hint that bubbling should cease and undo it anyways --- copyparty/web/baguettebox.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js index ef5b81f7..931d5195 100644 --- a/copyparty/web/baguettebox.js +++ b/copyparty/web/baguettebox.js @@ -44,6 +44,7 @@ window.baguetteBox = (function () { loopA = null, loopB = null, url_ts = null, + un_pp = 0, resume_mp = false; var onFSC = function (e) { @@ -337,6 +338,9 @@ window.baguetteBox = (function () { rotn(e.shiftKey ? -1 : 1); else if (kl == "y") dlpic(); + else + return; + return ev(e); } function anim() { @@ -460,6 +464,7 @@ window.baguetteBox = (function () { var k = (e.key || e.code) + ''; if (k == "Space" || k == "Spacebar" || k == " ") { + un_pp = Date.now(); return ev(e); } } @@ -786,8 +791,7 @@ window.baguetteBox = (function () { image.setAttribute('playsinline', '1'); // ios ignores poster image.onended = vidEnd; - image.onplay = function () { show_buttons(1); }; - image.onpause = function () { show_buttons(); }; + image.onplay = image.onpause = ppHandler; } image.alt = thumbnailElement ? thumbnailElement.alt || '' : ''; if (options.titleTag && imageCaption) @@ -802,6 +806,15 @@ window.baguetteBox = (function () { callback(); } + function ppHandler() { + var now = Date.now(); + if (now - un_pp < 50) { + un_pp = 0; + return playpause(); // browser undid space hotkey + } + show_buttons(this.paused ? 1 : 0); + } + function showNextImage(e) { ev(e); return show(currentIndex + 1);