diff --git a/frontend/index.html b/frontend/index.html
index 5f4bc8c..f3ed1cf 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -1145,8 +1145,8 @@
-
-
+
+
diff --git a/frontend/js/app.js b/frontend/js/app.js
index 4a976df..1bd36a2 100644
--- a/frontend/js/app.js
+++ b/frontend/js/app.js
@@ -64,6 +64,9 @@ function appliquerConfig() {
// Media d'accueil (video/gif en boucle)
appliquerMediaAccueil(event.media_accueil);
+
+ // Precharger image surprise
+ if (typeof prechargerSurprise === 'function') prechargerSurprise();
}
function appliquerMediaAccueil(media) {
diff --git a/frontend/js/camera.js b/frontend/js/camera.js
index 7aff00d..2c9f1b1 100644
--- a/frontend/js/camera.js
+++ b/frontend/js/camera.js
@@ -11,10 +11,21 @@ const EMOJI_CAR = { 3: '🤪', 2: '😱', 1: '🔥' };
// --- Surprise avant capture ---
+let _surprisePreloaded = null;
+
+function prechargerSurprise() {
+ const surprise = (config || {}).surprise;
+ if (!surprise || !surprise.actif || !surprise.fichier) return;
+ if (surprise.type === 'video') return;
+ const img = new Image();
+ img.src = '/api/surprise/media?t=' + Date.now();
+ _surprisePreloaded = img;
+}
+
async function afficherSurprise() {
const surprise = (config || {}).surprise;
if (!surprise || !surprise.actif || !surprise.fichier) return;
- const delai = surprise.delai_ms || 1000;
+ const delai = surprise.delai_ms || 1500;
const overlay = document.getElementById('surprise-overlay');
if (!overlay) return;
@@ -22,12 +33,32 @@ async function afficherSurprise() {
if (surprise.type === 'video') {
overlay.innerHTML = '';
} else {
- overlay.innerHTML = '
';
+ if (_surprisePreloaded && _surprisePreloaded.complete) {
+ _surprisePreloaded.style.cssText = 'max-width:100%;max-height:100%;object-fit:contain';
+ overlay.innerHTML = '';
+ overlay.appendChild(_surprisePreloaded);
+ } else {
+ overlay.innerHTML = '
';
+ const img = overlay.querySelector('img');
+ if (img && !img.complete) {
+ await new Promise(r => { img.onload = r; img.onerror = r; setTimeout(r, 500); });
+ }
+ }
}
+ overlay.style.opacity = '0';
overlay.classList.remove('cache');
+ overlay.style.transition = 'opacity 0.2s';
+ overlay.style.opacity = '1';
await new Promise(r => setTimeout(r, delai));
+
+ overlay.style.opacity = '0';
+ await new Promise(r => setTimeout(r, 200));
overlay.classList.add('cache');
+ overlay.style.transition = '';
+ overlay.style.opacity = '';
+
+ prechargerSurprise();
}
// --- Preview live ---