From 4c601234ef5888392d85dcd6d702e36781ae823b Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 6 Jan 2024 14:38:18 +0700 Subject: [PATCH] Fix the StreamHud buttons being wonky --- better-xcloud.user.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index 6bf16a1..a2aabdb 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -6951,7 +6951,7 @@ function addCss() { /* Fix Stream menu buttons not hiding */ div[class^=HUDButton-module__hiddenContainer] ~ div:not([class^=HUDButton-module__hiddenContainer]) { opacity: 0; - pointer-events: none; + pointer-events: none !important; position: absolute; top: -9999px; left: -9999px; @@ -9043,6 +9043,33 @@ function watchHeader() { function cloneStreamHudButton($orgButton, label, svg_icon) { const $container = $orgButton.cloneNode(true); + let timeout; + + const onTransitionStart = e => { + if ( e.propertyName !== 'opacity') { + return; + } + + timeout && clearTimeout(timeout); + $container.style.pointerEvents = 'none'; + }; + + const onTransitionEnd = e => { + if ( e.propertyName !== 'opacity') { + return; + } + + const left = document.getElementById('StreamHud').style.left; + if (left === '0px') { + timeout && clearTimeout(timeout); + timeout = setTimeout(() => { + $container.style.pointerEvents = 'auto'; + }, 100); + } + }; + + $container.addEventListener('transitionstart', onTransitionStart); + $container.addEventListener('transitionend', onTransitionEnd); const $button = $container.querySelector('button'); $button.setAttribute('title', label);