Spaces:
Running
Running
Update interface.js
Browse files- interface.js +98 -2
interface.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
| 13 |
if (!playcanvasUrl) return;
|
| 14 |
|
| 15 |
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
|
|
| 16 |
const id = Math.random().toString(36).substr(2, 8);
|
| 17 |
|
| 18 |
// βββ 4. Calcul des ratios (Desktop & Mobile Portrait) ββββββββββββββββββββββββ
|
|
@@ -73,10 +74,12 @@
|
|
| 73 |
border: none;
|
| 74 |
display: block;
|
| 75 |
}
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
| 77 |
position: absolute;
|
| 78 |
top: 10px;
|
| 79 |
-
right: 10px;
|
| 80 |
z-index: 10;
|
| 81 |
width: 36px;
|
| 82 |
height: 36px;
|
|
@@ -90,6 +93,46 @@
|
|
| 90 |
cursor: pointer;
|
| 91 |
user-select: none;
|
| 92 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
`;
|
| 94 |
document.head.appendChild(style);
|
| 95 |
|
|
@@ -112,9 +155,45 @@
|
|
| 112 |
fsBtn.className = `pc-fs-btn-${id}`;
|
| 113 |
fsBtn.textContent = 'β±';
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
inner.appendChild(iframe);
|
| 116 |
wrapper.appendChild(inner);
|
|
|
|
| 117 |
wrapper.appendChild(fsBtn);
|
|
|
|
| 118 |
scriptTag.parentNode.insertBefore(wrapper, scriptTag.nextSibling);
|
| 119 |
|
| 120 |
// βββ 7. Γtat & Helper ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -126,6 +205,22 @@
|
|
| 126 |
return (CSS && CSS.supports && CSS.supports('height', '100dvh')) ? '100dvh' : '100vh';
|
| 127 |
}
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
// βββ 8. Styles Plein Γcran βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 130 |
function applyFullscreenStyles() {
|
| 131 |
const h = isIOS ? getHeightUnit() : '100vh';
|
|
@@ -166,6 +261,7 @@
|
|
| 166 |
|
| 167 |
// βββ 9. Gestionnaires d'Γ©vΓ©nements βββββββββββββββββββββββββββββββββββββββββββ
|
| 168 |
function enterFullscreen() {
|
|
|
|
| 169 |
if (isIOS) {
|
| 170 |
applyFakeFullscreenStyles();
|
| 171 |
document.body.style.overflow = 'hidden';
|
|
|
|
| 13 |
if (!playcanvasUrl) return;
|
| 14 |
|
| 15 |
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
| 16 |
+
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 17 |
const id = Math.random().toString(36).substr(2, 8);
|
| 18 |
|
| 19 |
// βββ 4. Calcul des ratios (Desktop & Mobile Portrait) ββββββββββββββββββββββββ
|
|
|
|
| 74 |
border: none;
|
| 75 |
display: block;
|
| 76 |
}
|
| 77 |
+
|
| 78 |
+
/* ββ Boutons (fullscreen + help) ββ */
|
| 79 |
+
.pc-fs-btn-${id},
|
| 80 |
+
.pc-help-btn-${id} {
|
| 81 |
position: absolute;
|
| 82 |
top: 10px;
|
|
|
|
| 83 |
z-index: 10;
|
| 84 |
width: 36px;
|
| 85 |
height: 36px;
|
|
|
|
| 93 |
cursor: pointer;
|
| 94 |
user-select: none;
|
| 95 |
}
|
| 96 |
+
.pc-fs-btn-${id} {
|
| 97 |
+
right: 10px;
|
| 98 |
+
}
|
| 99 |
+
.pc-help-btn-${id} {
|
| 100 |
+
right: 54px; /* 10px + 36px + 8px de marge */
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/* ββ Panneau d'aide ββ */
|
| 104 |
+
.pc-help-panel-${id} {
|
| 105 |
+
display: none;
|
| 106 |
+
position: absolute;
|
| 107 |
+
top: 54px;
|
| 108 |
+
right: 10px;
|
| 109 |
+
z-index: 20;
|
| 110 |
+
background: #2E2E2EB3;
|
| 111 |
+
color: #fff;
|
| 112 |
+
border-radius: 8px;
|
| 113 |
+
padding: 10px 14px 10px 14px;
|
| 114 |
+
font-size: 13px;
|
| 115 |
+
line-height: 1.7;
|
| 116 |
+
min-width: 220px;
|
| 117 |
+
max-width: 80%;
|
| 118 |
+
box-sizing: border-box;
|
| 119 |
+
}
|
| 120 |
+
.pc-help-panel-${id}.visible {
|
| 121 |
+
display: block;
|
| 122 |
+
}
|
| 123 |
+
.pc-help-close-${id} {
|
| 124 |
+
position: absolute;
|
| 125 |
+
top: 4px;
|
| 126 |
+
right: 10px;
|
| 127 |
+
cursor: pointer;
|
| 128 |
+
font-size: 18px;
|
| 129 |
+
line-height: 1;
|
| 130 |
+
color: #fff;
|
| 131 |
+
user-select: none;
|
| 132 |
+
}
|
| 133 |
+
.pc-help-text-${id} {
|
| 134 |
+
margin-top: 4px;
|
| 135 |
+
}
|
| 136 |
`;
|
| 137 |
document.head.appendChild(style);
|
| 138 |
|
|
|
|
| 155 |
fsBtn.className = `pc-fs-btn-${id}`;
|
| 156 |
fsBtn.textContent = 'β±';
|
| 157 |
|
| 158 |
+
const helpBtn = document.createElement('button');
|
| 159 |
+
helpBtn.className = `pc-help-btn-${id}`;
|
| 160 |
+
helpBtn.textContent = '?';
|
| 161 |
+
|
| 162 |
+
// Panneau d'aide
|
| 163 |
+
const helpPanel = document.createElement('div');
|
| 164 |
+
helpPanel.className = `pc-help-panel-${id}`;
|
| 165 |
+
|
| 166 |
+
const helpClose = document.createElement('span');
|
| 167 |
+
helpClose.className = `pc-help-close-${id}`;
|
| 168 |
+
helpClose.textContent = 'Γ';
|
| 169 |
+
|
| 170 |
+
const helpText = document.createElement('div');
|
| 171 |
+
helpText.className = `pc-help-text-${id}`;
|
| 172 |
+
|
| 173 |
+
if (isMobile) {
|
| 174 |
+
helpText.innerHTML =
|
| 175 |
+
'- Se déplacer avec les flèches.<br>' +
|
| 176 |
+
'- Tourner avec un doigt.<br>' +
|
| 177 |
+
'- Zoomer avec deux doigts.<br>' +
|
| 178 |
+
'- β± plein Γ©cran.<br>' +
|
| 179 |
+
'- Modifier la qualitΓ© avec le menu Γ gauche.';
|
| 180 |
+
} else {
|
| 181 |
+
helpText.innerHTML =
|
| 182 |
+
'- Se déplacer avec les flèches ou Z, Q, S, D.<br>' +
|
| 183 |
+
'- Tourner avec clic droit.<br>' +
|
| 184 |
+
'- Zoomer avec la molette.<br>' +
|
| 185 |
+
'- β± plein Γ©cran.<br>' +
|
| 186 |
+
'- Modifier la qualitΓ© avec le menu Γ gauche.';
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
helpPanel.appendChild(helpClose);
|
| 190 |
+
helpPanel.appendChild(helpText);
|
| 191 |
+
|
| 192 |
inner.appendChild(iframe);
|
| 193 |
wrapper.appendChild(inner);
|
| 194 |
+
wrapper.appendChild(helpBtn);
|
| 195 |
wrapper.appendChild(fsBtn);
|
| 196 |
+
wrapper.appendChild(helpPanel);
|
| 197 |
scriptTag.parentNode.insertBefore(wrapper, scriptTag.nextSibling);
|
| 198 |
|
| 199 |
// βββ 7. Γtat & Helper ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 205 |
return (CSS && CSS.supports && CSS.supports('height', '100dvh')) ? '100dvh' : '100vh';
|
| 206 |
}
|
| 207 |
|
| 208 |
+
// βββ Gestion du panneau d'aide βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 209 |
+
function toggleHelpPanel(e) {
|
| 210 |
+
e.stopPropagation();
|
| 211 |
+
helpPanel.classList.toggle('visible');
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
function hideHelpPanel() {
|
| 215 |
+
helpPanel.classList.remove('visible');
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
helpBtn.addEventListener('click', toggleHelpPanel);
|
| 219 |
+
helpClose.addEventListener('click', (e) => {
|
| 220 |
+
e.stopPropagation();
|
| 221 |
+
hideHelpPanel();
|
| 222 |
+
});
|
| 223 |
+
|
| 224 |
// βββ 8. Styles Plein Γcran βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 225 |
function applyFullscreenStyles() {
|
| 226 |
const h = isIOS ? getHeightUnit() : '100vh';
|
|
|
|
| 261 |
|
| 262 |
// βββ 9. Gestionnaires d'Γ©vΓ©nements βββββββββββββββββββββββββββββββββββββββββββ
|
| 263 |
function enterFullscreen() {
|
| 264 |
+
hideHelpPanel();
|
| 265 |
if (isIOS) {
|
| 266 |
applyFakeFullscreenStyles();
|
| 267 |
document.body.style.overflow = 'hidden';
|