mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Use {once: true} in some event listeners
This commit is contained in:
parent
277c777121
commit
d31a06be89
@ -11,8 +11,6 @@ export function patchVideoApi() {
|
||||
// Show video player when it's ready
|
||||
const showFunc = function(this: HTMLVideoElement) {
|
||||
this.style.visibility = 'visible';
|
||||
this.removeEventListener('playing', showFunc);
|
||||
|
||||
if (!this.videoWidth) {
|
||||
return;
|
||||
}
|
||||
@ -49,7 +47,7 @@ export function patchVideoApi() {
|
||||
const $parent = this.parentElement!!;
|
||||
// Video tag is stream player
|
||||
if (!this.src && $parent.dataset.testid === 'media-container') {
|
||||
this.addEventListener('playing', showFunc);
|
||||
this.addEventListener('loadedmetadata', showFunc, {once: true});
|
||||
}
|
||||
|
||||
return nativePlay.apply(this);
|
||||
|
@ -57,7 +57,7 @@ export class Screenshot {
|
||||
return;
|
||||
}
|
||||
|
||||
$player.parentElement!.addEventListener('animationend', this.#onAnimationEnd);
|
||||
$player.parentElement!.addEventListener('animationend', this.#onAnimationEnd, { once: true });
|
||||
$player.parentElement!.classList.add('bx-taking-screenshot');
|
||||
|
||||
const canvasContext = Screenshot.#canvasContext;
|
||||
|
Loading…
x
Reference in New Issue
Block a user