live: fix double-click fullscreen — return to grid in mode 1, solo-only in mode 2

Track whether fullscreen was entered by the double-click itself (_fsBySolo).
Mode 1 (from the grid): a double-click fullscreens the camera and a second
double-click now exits fullscreen back to live view. Mode 2 (already in
fullscreen via F): double-click toggles solo/grid without leaving fullscreen;
Esc or F exits. Exiting fullscreen by any means resets the flag and clears solo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 22:48:02 +05:00
parent c2b698e1f4
commit 0216d2c1f1
2 changed files with 23 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
0.0.145
0.0.146
+22 -8
View File
@@ -505,7 +505,7 @@ class WebCodecsHevcPlayer {
// Страница LIVE VIEW
// ════════════════════════════════════════════════════════════════
const Live = {
cameras: [], dim: 2, layout: 4, transcode: false, go2rtcUrl: "", selected: [], singleMain: false, maxDim: 8, playing: true, page: 0,
cameras: [], dim: 2, layout: 4, transcode: false, go2rtcUrl: "", selected: [], singleMain: false, maxDim: 8, playing: true, page: 0, _fsBySolo: false,
async init() {
const data = await api("/api/cameras");
@@ -652,8 +652,11 @@ const Live = {
if (this._fsBound) return;
this._fsBound = true;
const onFs = () => {
// выход из фуллскрина (в т.ч. по ESC) — снять «соло», вернуться к сетке
if (!(document.fullscreenElement || document.webkitFullscreenElement)) this.clearSolo();
// выход из фуллскрина (в т.ч. по ESC/F) — сбросить флаг и «соло», вернуться к сетке
if (!(document.fullscreenElement || document.webkitFullscreenElement)) {
this._fsBySolo = false;
this.clearSolo();
}
this.resizePlayers();
};
document.addEventListener("fullscreenchange", onFs);
@@ -853,16 +856,27 @@ const Live = {
grid.querySelectorAll(".tile.solo").forEach((t) => t.classList.remove("solo"));
},
toggleSolo(tile) { // одна камера на весь экран (внутри полноэкранного режима)
// Двойной клик по камере.
// Режим 1 (из сетки): вход в фуллскрин этой камеры; повторный двойной клик — выход в live view.
// Режим 2 (уже в фуллскрине по F): соло ↔ сетка без выхода из фуллскрина (выход — Esc/F).
toggleSolo(tile) {
const grid = document.getElementById("grid");
const isFs = !!(document.fullscreenElement || document.webkitFullscreenElement);
const wasSolo = grid.classList.contains("solo") && tile.classList.contains("solo");
this.clearSolo();
if (!wasSolo) { // включить «соло» этой ячейки
if (wasSolo) {
if (this._fsBySolo) { // режим 1: фуллскрин включён самим кликом → назад в live view
this._fsBySolo = false;
if (isFs) toggleFullscreen(document.getElementById("live-main") || grid);
} // режим 2 (вошли по F): остаёмся в фуллскрине — просто сетка
} else {
grid.classList.add("solo");
tile.classList.add("solo");
// ещё не в полноэкранном — войти, чтобы камера заняла весь экран (выход — ESC)
if (!(document.fullscreenElement || document.webkitFullscreenElement)) toggleFullscreen(document.getElementById("live-main") || grid);
} // повторный двойной клик — назад к сетке (фуллскрин сохраняется)
if (!isFs) { // режим 1: входим в фуллскрин этой камеры
this._fsBySolo = true;
toggleFullscreen(document.getElementById("live-main") || grid);
}
}
this.resizePlayers();
},