Feature: Dark-Mode Overlay auf Welten-Panorama (rgba 0,0,0,0.45), SW by-v1033
This commit is contained in:
parent
a1c4d2ab2b
commit
a65e5a2723
4 changed files with 22 additions and 5 deletions
|
|
@ -982,6 +982,19 @@ window.Worlds = (() => {
|
|||
|
||||
let _bgUrl = null; // aktuell gesetztes Hintergrundbild
|
||||
|
||||
function _isDarkMode() {
|
||||
const t = document.documentElement.getAttribute('data-theme');
|
||||
if (t === 'dark') return true;
|
||||
if (t === 'light') return false;
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
}
|
||||
|
||||
function _bgWithOverlay(url) {
|
||||
return _isDarkMode()
|
||||
? `linear-gradient(rgba(0,0,0,0.45),rgba(0,0,0,0.45)), url('${url}')`
|
||||
: `url('${url}')`;
|
||||
}
|
||||
|
||||
function _applyBgOrientation() {
|
||||
const ov = document.getElementById('worlds-overlay');
|
||||
const track = document.getElementById('worlds-track');
|
||||
|
|
@ -990,14 +1003,14 @@ window.Worlds = (() => {
|
|||
if (portrait) {
|
||||
// Panorama: Bild über alle drei Welten, scrollt mit dem Swipe
|
||||
ov.style.backgroundImage = '';
|
||||
track.style.backgroundImage = `url('${_bgUrl}')`;
|
||||
track.style.backgroundImage = _bgWithOverlay(_bgUrl);
|
||||
track.style.backgroundSize = 'cover';
|
||||
track.style.backgroundPosition = 'center 40%';
|
||||
track.style.backgroundRepeat = 'no-repeat';
|
||||
} else {
|
||||
// Vollbild pro Welt (Landscape / Desktop)
|
||||
track.style.backgroundImage = '';
|
||||
ov.style.backgroundImage = `url('${_bgUrl}')`;
|
||||
ov.style.backgroundImage = _bgWithOverlay(_bgUrl);
|
||||
ov.style.backgroundSize = 'cover';
|
||||
ov.style.backgroundPosition = 'center 40%';
|
||||
ov.style.backgroundRepeat = 'no-repeat';
|
||||
|
|
@ -1007,6 +1020,10 @@ window.Worlds = (() => {
|
|||
// Orientierungswechsel → Bild neu setzen
|
||||
window.matchMedia('(orientation: portrait)').addEventListener('change', _applyBgOrientation);
|
||||
|
||||
// Theme-Wechsel → Overlay-Intensität anpassen
|
||||
new MutationObserver(_applyBgOrientation)
|
||||
.observe(document.documentElement, { attributeFilter: ['data-theme'] });
|
||||
|
||||
function _applyBgImage(url) {
|
||||
const ov = document.getElementById('worlds-overlay');
|
||||
const track = document.getElementById('worlds-track');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue