Skip to content

Commit bbf483b

Browse files
committed
Fix an issue where the initial button press does not work on a touch device (tested with chromebook in touch mode), due to the fact that the mouseenter event gets triggered when you click the button, causing both mouseevent and click event to trigger right after each other, making the click cancel out the touchenter event. It fixes it by keeping track of when the last displayType (hide / show) happened, and rejecting it when the time between the last one and the current one is less than 16 milliseconds ago.
1 parent 42dc804 commit bbf483b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/quality/quality.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,29 @@ Object.assign(MediaElementPlayer.prototype, {
194194
labels = player.qualitiesContainer.querySelectorAll(`.${t.options.classPrefix}qualities-selector-label`)
195195
;
196196

197+
let lastShowChange = Date.now();
197198
function hideSelector() {
199+
const now = Date.now();
200+
const diff = now - lastShowChange;
201+
if(diff < 16) {
202+
return;
203+
}
204+
lastShowChange = now;
205+
198206
mejs.Utils.addClass(qualitiesSelector, `${t.options.classPrefix}offscreen`);
199207
qualityButton.setAttribute('aria-expanded', 'false');
200208
qualityButton.focus();
201209
isHidden = true;
202210
}
203211

204212
function showSelector() {
213+
const now = Date.now();
214+
const diff = now - lastShowChange;
215+
if(diff < 16) {
216+
return;
217+
}
218+
lastShowChange = now;
219+
205220
mejs.Utils.removeClass(qualitiesSelector, `${t.options.classPrefix}offscreen`);
206221
qualitiesSelector.style.height = `${qualitiesSelector.querySelector('ul').offsetHeight}px`;
207222
qualitiesSelector.style.top = `${(-1 * parseFloat(qualitiesSelector.offsetHeight))}px`;

0 commit comments

Comments
 (0)