Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve seekOnTaps behavior on tap and scroll #8221

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ui/hidden_seek_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ shaka.ui.HiddenSeekButton = class extends shaka.ui.Element {
/** @private {?boolean} */
this.triggeredTouchValid_ = false;

/** @private {boolean} */
this.validTouchStart_ = false;

/**
* This timer will be used to hide seek button on video Container.
* When the timer ticks it will force button to be invisible.
Expand All @@ -48,7 +51,15 @@ shaka.ui.HiddenSeekButton = class extends shaka.ui.Element {
this.seekContainer = shaka.util.Dom.createHTMLElement('div');
this.parent.appendChild(this.seekContainer);

this.eventManager.listen(this.seekContainer, 'touchstart', (event) => {
this.validTouchStart_ = true;
});

this.eventManager.listen(this.seekContainer, 'touchend', (event) => {
if (!this.validTouchStart_) {
return;
}
this.validTouchStart_ = false;
// Do nothing if the controls are not visible
if (!this.controls.isOpaque()) {
return;
Expand Down Expand Up @@ -93,8 +104,8 @@ shaka.ui.HiddenSeekButton = class extends shaka.ui.Element {
if (!this.triggeredTouchValid_) {
this.triggeredTouchValid_ = true;
this.lastTouchEventTimeSet_ = Date.now();
this.hideSeekButtonContainerTimer_.tickAfter(1);
} else if (this.lastTouchEventTimeSet_+1000 > Date.now()) {
this.hideSeekButtonContainerTimer_.tickAfter(0.5);
} else if ((this.lastTouchEventTimeSet_ + 1000) > Date.now()) {
// stops hiding of seek button incase the timer is active
// because of previous touch event.
this.hideSeekButtonContainerTimer_.stop();
Expand Down