mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 08:07:18 +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
|
// Show video player when it's ready
|
||||||
const showFunc = function(this: HTMLVideoElement) {
|
const showFunc = function(this: HTMLVideoElement) {
|
||||||
this.style.visibility = 'visible';
|
this.style.visibility = 'visible';
|
||||||
this.removeEventListener('playing', showFunc);
|
|
||||||
|
|
||||||
if (!this.videoWidth) {
|
if (!this.videoWidth) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -49,7 +47,7 @@ export function patchVideoApi() {
|
|||||||
const $parent = this.parentElement!!;
|
const $parent = this.parentElement!!;
|
||||||
// Video tag is stream player
|
// Video tag is stream player
|
||||||
if (!this.src && $parent.dataset.testid === 'media-container') {
|
if (!this.src && $parent.dataset.testid === 'media-container') {
|
||||||
this.addEventListener('playing', showFunc);
|
this.addEventListener('loadedmetadata', showFunc, {once: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
return nativePlay.apply(this);
|
return nativePlay.apply(this);
|
||||||
|
@ -57,7 +57,7 @@ export class Screenshot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$player.parentElement!.addEventListener('animationend', this.#onAnimationEnd);
|
$player.parentElement!.addEventListener('animationend', this.#onAnimationEnd, { once: true });
|
||||||
$player.parentElement!.classList.add('bx-taking-screenshot');
|
$player.parentElement!.classList.add('bx-taking-screenshot');
|
||||||
|
|
||||||
const canvasContext = Screenshot.#canvasContext;
|
const canvasContext = Screenshot.#canvasContext;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user