mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-28 16:32:28 +00:00
Prevent VideoCard clicks from navigating
This commit is contained in:
1 parent
0843c70123
commit
ae6ba0d9e0
1 file changed
+25
-2
@@ -983,12 +983,35 @@ export class VideoCard {
|
||||
this.ensureGlobalMoreMenuHandlers();
|
||||
}
|
||||
|
||||
const MouseEventCtor = this.window?.MouseEvent || globalThis.MouseEvent;
|
||||
|
||||
[this.anchorEl, this.titleEl].forEach((el) => {
|
||||
if (!el) return;
|
||||
el.addEventListener("click", (event) => {
|
||||
if (this.callbacks.onPlay) {
|
||||
this.callbacks.onPlay({ event, video: this.video, card: this });
|
||||
if (!this.callbacks.onPlay) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isMouseEvent =
|
||||
typeof MouseEventCtor !== "undefined" && event instanceof MouseEventCtor;
|
||||
if (isMouseEvent) {
|
||||
const isPrimaryClick =
|
||||
typeof event.button !== "number" || event.button === 0;
|
||||
const hasModifier =
|
||||
event.ctrlKey || event.metaKey || event.shiftKey || event.altKey;
|
||||
if (!isPrimaryClick || hasModifier) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof event.preventDefault === "function") {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (typeof event.stopPropagation === "function") {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
this.callbacks.onPlay({ event, video: this.video, card: this });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user