From 9a2d579e0e21081bb66d532679dfadd7035d5021 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 8 May 2020 17:58:17 +0200 Subject: controls.hide(): Hide controls immediately Don't use `wait_element` to hide the controls. I had done that because I thought that the element wasn't there after clicking the "Watch Credits" button, and I had to wait for it before trying to hide it. Turns out the reason why the credits weren't hiding was that I just shadowed the `controls` variable. This waiting isn't necessary, and in fact it's undesirable, because it causes the player controls to appear for a second before being hidden instead of not appearing at all. --- src/controls.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/controls.ts b/src/controls.ts index ad8f47c..5cff2d1 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -1,22 +1,21 @@ import logger from './logger'; -import wait_element from './wait_element'; const controls = { hide: function() { logger.debug('hide():', 'Hiding controls'); - wait_element('.PlayerControlsNeo__layout.PlayerControlsNeo__layout--active') - .then(function(controls) { - logger.debug('hide():', 'Controls:', controls); + const controls_el = document.querySelector( + '.PlayerControlsNeo__layout.PlayerControlsNeo__layout--active' + ); + logger.debug('hide():', 'Controls:', controls_el); - controls - .classList - .replace( - 'PlayerControlsNeo__layout--active', - 'PlayerControlsNeo__layout--inactive' - ); - }); + controls_el + .classList + .replace( + 'PlayerControlsNeo__layout--active', + 'PlayerControlsNeo__layout--inactive' + ); } }; -- cgit v1.2.3