From e6fa3d7e54019cebecf76b9a58ff2ee00b0ec816 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Thu, 26 Sep 2019 12:58:15 +0200 Subject: [PATCH] HFP-1763 Simplify logic --- js/h5p.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index aed2cfd..4e44806 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -365,21 +365,9 @@ H5P.init = function (target) { H5P.trigger(instance, 'resize'); // Logic for hiding focus effects when using mouse - const wrapper = $element[0]; - wrapper.classList.add('using-mouse'); - - // Switch between focus modes - wrapper.addEventListener('mousedown', function () { - wrapper.classList.add('using-mouse'); - }); - - wrapper.addEventListener('keydown', function () { - wrapper.classList.remove('using-mouse'); - }); - - // Make sure using-mouse is removed on the first tab into content as well - wrapper.addEventListener('keyup', function () { - wrapper.classList.remove('using-mouse'); + $element.addClass('using-mouse'); + $element.on('mousedown keydown keyup', function (event) { + $element.toggleClass('using-mouse', event.type === 'mousedown'); }); });