MikaFil commited on
Commit
403549d
·
verified ·
1 Parent(s): 464def1

Update interface.js

Browse files
Files changed (1) hide show
  1. interface.js +13 -4
interface.js CHANGED
@@ -49,17 +49,26 @@ const currentScriptTag = document.currentScript;
49
  const instanceId = Math.random().toString(36).substr(2, 8);
50
 
51
  // 4) Aspect ratio
 
 
 
 
 
 
 
 
 
52
  let aspectPercent = '100%';
53
- if (config.aspect) {
54
- if (config.aspect.includes(':')) {
55
- const parts = config.aspect.split(':');
56
  const w = parseFloat(parts[0]);
57
  const h = parseFloat(parts[1]);
58
  if (!isNaN(w) && !isNaN(h) && w > 0) {
59
  aspectPercent = (h / w) * 100 + '%';
60
  }
61
  } else {
62
- const aspectValue = parseFloat(config.aspect);
63
  if (!isNaN(aspectValue) && aspectValue > 0) {
64
  aspectPercent = 100 / aspectValue + '%';
65
  }
 
49
  const instanceId = Math.random().toString(36).substr(2, 8);
50
 
51
  // 4) Aspect ratio
52
+ // ── Détection mobile anticipée (isMobile est redéfini proprement en §7) ──
53
+ const _isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
54
+ const _isMobile = _isIOS || /Android/i.test(navigator.userAgent);
55
+
56
+ // Sélection de la clé d'aspect : mobile-aspect en priorité sur mobile, sinon aspect
57
+ const activeAspectValue = (_isMobile && config['mobile-aspect'])
58
+ ? config['mobile-aspect']
59
+ : config.aspect;
60
+
61
  let aspectPercent = '100%';
62
+ if (activeAspectValue) {
63
+ if (activeAspectValue.includes(':')) {
64
+ const parts = activeAspectValue.split(':');
65
  const w = parseFloat(parts[0]);
66
  const h = parseFloat(parts[1]);
67
  if (!isNaN(w) && !isNaN(h) && w > 0) {
68
  aspectPercent = (h / w) * 100 + '%';
69
  }
70
  } else {
71
+ const aspectValue = parseFloat(activeAspectValue);
72
  if (!isNaN(aspectValue) && aspectValue > 0) {
73
  aspectPercent = 100 / aspectValue + '%';
74
  }