feat: hide top frame in landscape orientation (v0.8.0)

This commit is contained in:
2026-05-06 13:52:43 +00:00
parent f21e02a16d
commit 4495aa4dfe
2 changed files with 29 additions and 1 deletions
+5
View File
@@ -42,6 +42,11 @@ top_max_height_vh: 35 # optional, only for layout: split — caps t
# full-frame top section at this many vh units # full-frame top section at this many vh units
# (default 35). Lower this if the top half feels # (default 35). Lower this if the top half feels
# too dominant on tall portrait screens. # too dominant on tall portrait screens.
landscape_hide_top: true # optional, only for layout: split — when true
# (default), hides the top full-frame view on
# landscape orientation since the cropped bottom
# already fills the screen well. Set false to
# keep the split in landscape too.
layout: split # optional — 'split' (default), 'cover', or 'contain' layout: split # optional — 'split' (default), 'cover', or 'contain'
# split: top half shows the full uncropped frame, # split: top half shows the full uncropped frame,
# bottom half is a center-cropped 'cover' view. # bottom half is a center-cropped 'cover' view.
+24 -1
View File
@@ -24,7 +24,7 @@
}; };
})(); })();
const VERSION = '0.7.2'; const VERSION = '0.8.0';
class WebrtcDoorbellCard extends HTMLElement { class WebrtcDoorbellCard extends HTMLElement {
setConfig(config) { setConfig(config) {
@@ -209,6 +209,22 @@ class WebrtcDoorbellCard extends HTMLElement {
stack.appendChild(this._topFrame); stack.appendChild(this._topFrame);
stack.appendChild(this._bottomVideo); stack.appendChild(this._bottomVideo);
// In landscape, the camera fits naturally on the screen — drop the
// top contain-view and let the bottom cover-view fill everything.
// Set `landscape_hide_top: false` to keep the split in landscape.
if (this._config.landscape_hide_top !== false) {
const mql = window.matchMedia('(orientation: landscape)');
const apply = (matches) => {
this._topFrame.style.display = matches ? 'none' : '';
};
apply(mql.matches);
const handler = (e) => apply(e.matches);
if (mql.addEventListener) mql.addEventListener('change', handler);
else mql.addListener(handler);
this._orientationMql = mql;
this._orientationHandler = handler;
}
} }
_mirrorStream() { _mirrorStream() {
@@ -242,6 +258,13 @@ class WebrtcDoorbellCard extends HTMLElement {
disconnectedCallback() { disconnectedCallback() {
clearInterval(this._mirrorInterval); clearInterval(this._mirrorInterval);
this._mirrorInterval = null; this._mirrorInterval = null;
if (this._orientationMql && this._orientationHandler) {
if (this._orientationMql.removeEventListener) {
this._orientationMql.removeEventListener('change', this._orientationHandler);
} else {
this._orientationMql.removeListener(this._orientationHandler);
}
}
} }
_makeBtn(icon, bg, onClick) { _makeBtn(icon, bg, onClick) {