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:
+22
-8
@@ -505,7 +505,7 @@ class WebCodecsHevcPlayer {
|
|||||||
// Страница LIVE VIEW
|
// Страница LIVE VIEW
|
||||||
// ════════════════════════════════════════════════════════════════
|
// ════════════════════════════════════════════════════════════════
|
||||||
const Live = {
|
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() {
|
async init() {
|
||||||
const data = await api("/api/cameras");
|
const data = await api("/api/cameras");
|
||||||
@@ -652,8 +652,11 @@ const Live = {
|
|||||||
if (this._fsBound) return;
|
if (this._fsBound) return;
|
||||||
this._fsBound = true;
|
this._fsBound = true;
|
||||||
const onFs = () => {
|
const onFs = () => {
|
||||||
// выход из фуллскрина (в т.ч. по ESC) — снять «соло», вернуться к сетке
|
// выход из фуллскрина (в т.ч. по ESC/F) — сбросить флаг и «соло», вернуться к сетке
|
||||||
if (!(document.fullscreenElement || document.webkitFullscreenElement)) this.clearSolo();
|
if (!(document.fullscreenElement || document.webkitFullscreenElement)) {
|
||||||
|
this._fsBySolo = false;
|
||||||
|
this.clearSolo();
|
||||||
|
}
|
||||||
this.resizePlayers();
|
this.resizePlayers();
|
||||||
};
|
};
|
||||||
document.addEventListener("fullscreenchange", onFs);
|
document.addEventListener("fullscreenchange", onFs);
|
||||||
@@ -853,16 +856,27 @@ const Live = {
|
|||||||
grid.querySelectorAll(".tile.solo").forEach((t) => t.classList.remove("solo"));
|
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 grid = document.getElementById("grid");
|
||||||
|
const isFs = !!(document.fullscreenElement || document.webkitFullscreenElement);
|
||||||
const wasSolo = grid.classList.contains("solo") && tile.classList.contains("solo");
|
const wasSolo = grid.classList.contains("solo") && tile.classList.contains("solo");
|
||||||
this.clearSolo();
|
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");
|
grid.classList.add("solo");
|
||||||
tile.classList.add("solo");
|
tile.classList.add("solo");
|
||||||
// ещё не в полноэкранном — войти, чтобы камера заняла весь экран (выход — ESC)
|
if (!isFs) { // режим 1: входим в фуллскрин этой камеры
|
||||||
if (!(document.fullscreenElement || document.webkitFullscreenElement)) toggleFullscreen(document.getElementById("live-main") || grid);
|
this._fsBySolo = true;
|
||||||
} // повторный двойной клик — назад к сетке (фуллскрин сохраняется)
|
toggleFullscreen(document.getElementById("live-main") || grid);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.resizePlayers();
|
this.resizePlayers();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user