MikaFil commited on
Commit
b6f5e3a
Β·
verified Β·
1 Parent(s): 403549d

Update interface.js

Browse files
Files changed (1) hide show
  1. interface.js +71 -31
interface.js CHANGED
@@ -386,23 +386,29 @@ const currentScriptTag = document.currentScript;
386
  // ─────────────────────────────────────────────────────────────────────────────
387
  // 14) Fullscreen
388
  // ─────────────────────────────────────────────────────────────────────────────
389
- let isFullscreen = false;
390
- let savedState = null;
 
 
 
 
 
 
391
 
392
  function saveCurrentState() {
393
  if (isFullscreen) return;
394
  const originalAspect = widgetContainer.getAttribute('data-original-aspect') || aspectPercent;
395
  savedState = {
396
  widget: {
397
- position: widgetContainer.style.position,
398
- top: widgetContainer.style.top,
399
- left: widgetContainer.style.left,
400
- width: widgetContainer.style.width,
401
- height: widgetContainer.style.height,
402
- maxWidth: widgetContainer.style.maxWidth,
403
- maxHeight: widgetContainer.style.maxHeight,
404
  paddingBottom: widgetContainer.style.paddingBottom || originalAspect,
405
- margin: widgetContainer.style.margin
406
  },
407
  viewer: {
408
  borderRadius: viewerContainerElem.style.borderRadius,
@@ -415,15 +421,16 @@ const currentScriptTag = document.currentScript;
415
  if (!savedState) return;
416
  const aspectToUse = savedState.widget.paddingBottom;
417
 
418
- widgetContainer.style.position = savedState.widget.position || '';
419
- widgetContainer.style.top = savedState.widget.top || '';
420
- widgetContainer.style.left = savedState.widget.left || '';
421
- widgetContainer.style.width = '100%';
422
- widgetContainer.style.height = '0';
423
- widgetContainer.style.maxWidth = savedState.widget.maxWidth || '';
424
- widgetContainer.style.maxHeight = savedState.widget.maxHeight || '';
425
  widgetContainer.style.paddingBottom = aspectToUse;
426
- widgetContainer.style.margin = savedState.widget.margin || '';
 
427
  widgetContainer.classList.remove('fake-fullscreen');
428
 
429
  viewerContainerElem.style.position = 'absolute';
@@ -436,6 +443,14 @@ const currentScriptTag = document.currentScript;
436
  viewerContainerElem.style.borderRadius = savedState.viewer.borderRadius || '';
437
  viewerContainerElem.style.border = savedState.viewer.border || '';
438
 
 
 
 
 
 
 
 
 
439
  if (viewerModule.app) {
440
  viewerModule.app.resizeCanvas(viewerContainerElem.clientWidth, viewerContainerElem.clientHeight);
441
  }
@@ -446,17 +461,20 @@ const currentScriptTag = document.currentScript;
446
  }
447
 
448
  function applyFullscreenStyles() {
449
- widgetContainer.style.position = 'fixed';
450
- widgetContainer.style.top = '0';
451
- widgetContainer.style.left = '0';
452
- widgetContainer.style.width = '100vw';
453
- widgetContainer.style.height = '100vh';
454
- widgetContainer.style.maxWidth = '100vw';
455
- widgetContainer.style.maxHeight = '100vh';
 
 
456
  widgetContainer.style.paddingBottom = '0';
457
- widgetContainer.style.margin = '0';
458
- widgetContainer.style.border = 'none';
459
- widgetContainer.style.borderRadius = '0';
 
460
 
461
  viewerContainerElem.style.width = '100%';
462
  viewerContainerElem.style.height = '100%';
@@ -476,19 +494,24 @@ const currentScriptTag = document.currentScript;
476
  if (!savedState) saveCurrentState();
477
 
478
  if (isIOS) {
479
- applyFullscreenStyles();
 
 
 
 
480
  widgetContainer.classList.add('fake-fullscreen');
 
481
  } else if (widgetContainer.requestFullscreen) {
482
  widgetContainer
483
  .requestFullscreen()
484
  .then(applyFullscreenStyles)
485
  .catch(() => {
486
- applyFullscreenStyles();
487
  widgetContainer.classList.add('fake-fullscreen');
 
488
  });
489
  } else {
490
- applyFullscreenStyles();
491
  widgetContainer.classList.add('fake-fullscreen');
 
492
  }
493
  }
494
 
@@ -519,6 +542,23 @@ const currentScriptTag = document.currentScript;
519
  setMenuContentMaxSize();
520
  });
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  // ─────────────────────────────────────────────────────────────────────────────
523
  // 15) Boutons d'interface
524
  // ─────────────────────────────────────────────────────────────────────────────
 
386
  // ─────────────────────────────────────────────────────────────────────────────
387
  // 14) Fullscreen
388
  // ─────────────────────────────────────────────────────────────────────────────
389
+ let isFullscreen = false;
390
+ let savedState = null;
391
+ let savedParent = null; // ← nouveau : mΓ©morise le parent original sur iOS
392
+ let savedSibling = null; // ← nouveau : mΓ©morise le frΓ¨re suivant sur iOS
393
+
394
+ function getHeightUnit() {
395
+ return (CSS && CSS.supports && CSS.supports('height', '100dvh')) ? '100dvh' : '100vh';
396
+ }
397
 
398
  function saveCurrentState() {
399
  if (isFullscreen) return;
400
  const originalAspect = widgetContainer.getAttribute('data-original-aspect') || aspectPercent;
401
  savedState = {
402
  widget: {
403
+ position: widgetContainer.style.position,
404
+ top: widgetContainer.style.top,
405
+ left: widgetContainer.style.left,
406
+ width: widgetContainer.style.width,
407
+ height: widgetContainer.style.height,
408
+ maxWidth: widgetContainer.style.maxWidth,
409
+ maxHeight: widgetContainer.style.maxHeight,
410
  paddingBottom: widgetContainer.style.paddingBottom || originalAspect,
411
+ margin: widgetContainer.style.margin
412
  },
413
  viewer: {
414
  borderRadius: viewerContainerElem.style.borderRadius,
 
421
  if (!savedState) return;
422
  const aspectToUse = savedState.widget.paddingBottom;
423
 
424
+ widgetContainer.style.position = savedState.widget.position || '';
425
+ widgetContainer.style.top = savedState.widget.top || '';
426
+ widgetContainer.style.left = savedState.widget.left || '';
427
+ widgetContainer.style.width = '100%';
428
+ widgetContainer.style.height = '0';
429
+ widgetContainer.style.maxWidth = savedState.widget.maxWidth || '';
430
+ widgetContainer.style.maxHeight = savedState.widget.maxHeight || '';
431
  widgetContainer.style.paddingBottom = aspectToUse;
432
+ widgetContainer.style.margin = savedState.widget.margin || '';
433
+ widgetContainer.style.zIndex = '';
434
  widgetContainer.classList.remove('fake-fullscreen');
435
 
436
  viewerContainerElem.style.position = 'absolute';
 
443
  viewerContainerElem.style.borderRadius = savedState.viewer.borderRadius || '';
444
  viewerContainerElem.style.border = savedState.viewer.border || '';
445
 
446
+ // ── Remettre le nΕ“ud Γ  sa place d'origine dans le DOM (iOS) ──
447
+ if (savedParent) {
448
+ savedParent.insertBefore(widgetContainer, savedSibling);
449
+ savedParent = null;
450
+ savedSibling = null;
451
+ document.body.style.overflow = '';
452
+ }
453
+
454
  if (viewerModule.app) {
455
  viewerModule.app.resizeCanvas(viewerContainerElem.clientWidth, viewerContainerElem.clientHeight);
456
  }
 
461
  }
462
 
463
  function applyFullscreenStyles() {
464
+ const h = isIOS ? getHeightUnit() : '100vh';
465
+
466
+ widgetContainer.style.position = 'fixed';
467
+ widgetContainer.style.top = '0';
468
+ widgetContainer.style.left = '0';
469
+ widgetContainer.style.width = '100vw';
470
+ widgetContainer.style.height = h;
471
+ widgetContainer.style.maxWidth = '100vw';
472
+ widgetContainer.style.maxHeight = h;
473
  widgetContainer.style.paddingBottom = '0';
474
+ widgetContainer.style.margin = '0';
475
+ widgetContainer.style.zIndex = '99999';
476
+ widgetContainer.style.border = 'none';
477
+ widgetContainer.style.borderRadius = '0';
478
 
479
  viewerContainerElem.style.width = '100%';
480
  viewerContainerElem.style.height = '100%';
 
494
  if (!savedState) saveCurrentState();
495
 
496
  if (isIOS) {
497
+ // ── DΓ©placer dans <body> pour Γ©chapper au stacking context de Squarespace ──
498
+ savedParent = widgetContainer.parentNode;
499
+ savedSibling = widgetContainer.nextSibling;
500
+ document.body.appendChild(widgetContainer);
501
+ document.body.style.overflow = 'hidden';
502
  widgetContainer.classList.add('fake-fullscreen');
503
+ applyFullscreenStyles();
504
  } else if (widgetContainer.requestFullscreen) {
505
  widgetContainer
506
  .requestFullscreen()
507
  .then(applyFullscreenStyles)
508
  .catch(() => {
 
509
  widgetContainer.classList.add('fake-fullscreen');
510
+ applyFullscreenStyles();
511
  });
512
  } else {
 
513
  widgetContainer.classList.add('fake-fullscreen');
514
+ applyFullscreenStyles();
515
  }
516
  }
517
 
 
542
  setMenuContentMaxSize();
543
  });
544
 
545
+ // ── Resize : recalcule la hauteur en dvh sur iOS ──
546
+ window.addEventListener('resize', () => {
547
+ if (viewerModule.app) {
548
+ if (isFullscreen) {
549
+ viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
550
+ if (isIOS) {
551
+ const h = getHeightUnit();
552
+ widgetContainer.style.height = h;
553
+ widgetContainer.style.maxHeight = h;
554
+ }
555
+ } else {
556
+ viewerModule.app.resizeCanvas(viewerContainerElem.clientWidth, viewerContainerElem.clientHeight);
557
+ }
558
+ }
559
+ setMenuContentMaxSize();
560
+ });
561
+
562
  // ─────────────────────────────────────────────────────────────────────────────
563
  // 15) Boutons d'interface
564
  // ─────────────────────────────────────────────────────────────────────────────