vers. 3.0.2 - iPhone: il guscio riempie davvero lo schermo
Su iOS 26 (app installata) la finestra riportata al sito è più corta dello schermo di circa 60 punti, anche se la WebView lo copre tutto: vh, dvh e position: fixed lasciavano una fascia vuota sotto la tab bar. Ora js/app.js misura lo schermo e imposta l'altezza del guscio (--shell-h) solo su iPhone in modalità installata e a schermo intero. Player, banner PWA, finestra istruzioni, avviso offline e barra di avanzamento sono figli del guscio con position: absolute, così seguono il guscio e non il viewport. Cache del service worker v8. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
3aa7130880
commit
3cbffd5423
5 files changed
+58
-10
No files matched your search
@@ -758,7 +758,7 @@
|
||||
'<button type="button" class="btn btn-accent btn-lg offline-btn" id="offlineRetryBtn">' +
|
||||
'<svg class="icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>' +
|
||||
'<span>Riprova</span></button></div>';
|
||||
body.appendChild(overlay);
|
||||
(document.getElementById('app') || body).appendChild(overlay);
|
||||
|
||||
var btn = $('#offlineRetryBtn');
|
||||
btn.addEventListener('click', function () {
|
||||
@@ -814,8 +814,45 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* iPhone, app installata: iOS 26 riporta una finestra più corta dello schermo (di circa l'altezza della barra
|
||||
* di Safari) anche se la WebView copre tutto lo schermo. vh, dvh e position: fixed seguono quel valore e sotto
|
||||
* la tab bar resta una fascia vuota. Qui si misura lo schermo e si dà al guscio la sua altezza vera (--shell-h).
|
||||
*/
|
||||
var Schermo = {
|
||||
iphone: /iPhone|iPod/.test(navigator.userAgent),
|
||||
standalone: function () {
|
||||
return navigator.standalone === true || (window.matchMedia && window.matchMedia('(display-mode: standalone)').matches);
|
||||
},
|
||||
adatta: function () {
|
||||
var root = document.documentElement;
|
||||
if (!this.iphone || !this.standalone()) { root.style.removeProperty('--shell-h'); return; }
|
||||
var portrait = window.innerHeight >= window.innerWidth;
|
||||
var screenH = portrait ? Math.max(screen.width, screen.height) : Math.min(screen.width, screen.height);
|
||||
var screenW = portrait ? Math.min(screen.width, screen.height) : Math.max(screen.width, screen.height);
|
||||
var h = window.innerHeight;
|
||||
var differenza = screenH - h;
|
||||
// Solo a schermo intero e per uno scarto "da barra" (fino a 140 pt): altrimenti si lascia fare al CSS
|
||||
if (window.innerWidth === screenW && differenza > 2 && differenza <= 140) {
|
||||
root.style.setProperty('--shell-h', screenH + 'px');
|
||||
} else {
|
||||
root.style.removeProperty('--shell-h');
|
||||
}
|
||||
},
|
||||
init: function () {
|
||||
var self = this;
|
||||
var aggiorna = function () { self.adatta(); };
|
||||
aggiorna();
|
||||
window.addEventListener('resize', aggiorna);
|
||||
window.addEventListener('orientationchange', function () { setTimeout(aggiorna, 300); });
|
||||
window.addEventListener('pageshow', aggiorna);
|
||||
if (window.visualViewport) window.visualViewport.addEventListener('resize', aggiorna);
|
||||
}
|
||||
};
|
||||
|
||||
function init() {
|
||||
if (!content || gusciVecchio()) return;
|
||||
Schermo.init();
|
||||
Offline.init();
|
||||
Player.init();
|
||||
Podcast.init();
|
||||
|
||||
Reference in new issue
Block a user