Joffrey Thomas commited on
Commit
b0e694e
·
1 Parent(s): 5c48063

fullscreen

Browse files
Files changed (1) hide show
  1. app.py +24 -11
app.py CHANGED
@@ -297,10 +297,12 @@ def score_from_distance_km(distance_km: float) -> float:
297
  def build_street_html(image_url: str) -> str:
298
  base = """
299
  <div id="image-container" style="position:relative;max-width:960px;margin:0 auto;">
300
- <img id="street-image" src="__IMG_URL__" style="width:100%;height:auto;border-radius:8px;box-shadow:0 4px 6px rgba(0,0,0,0.1)" />
301
- <button id="fullscreen-btn" title="Toggle Fullscreen" style="position:absolute;top:10px;right:10px;z-index:10;background:rgba(0,0,0,0.5);border:none;color:white;padding:8px;border-radius:4px;cursor:pointer;line-height:0;">
302
- <!-- SVG icon will be injected by JS -->
303
- </button>
 
 
304
  <div id="mini-map-wrap" style="transition:all 0.3s ease;position:absolute;right:10px;bottom:10px;border:2px solid #fff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.2);background:#fff;">
305
  <div id="mini-map" style="width:100%;height:100%;cursor:pointer"></div>
306
  <div id="map-controls" style="position:absolute;right:8px;top:8px;display:flex;gap:6px;z-index:5;">
@@ -599,17 +601,24 @@ APP_BOOT_JS = """
599
  function initFullscreenButtonIfPresent() {
600
  log('initFullscreenButtonIfPresent called');
601
  const btn = document.getElementById('fullscreen-btn');
 
602
  const img = document.getElementById('street-image');
603
- if (!btn || !img || btn.dataset.initialized === '1') return;
604
 
605
  const enterIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>';
606
  const exitIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0-2-2h-3m-6 0H3a2 2 0 0 0-2 2v3"/></svg>';
607
 
608
  btn.innerHTML = enterIcon;
 
 
 
 
 
 
609
 
610
  btn.addEventListener('click', () => {
611
  if (!document.fullscreenElement) {
612
- img.requestFullscreen().catch(err => {
613
  log('Fullscreen error:', err);
614
  });
615
  } else {
@@ -618,14 +627,18 @@ APP_BOOT_JS = """
618
  });
619
 
620
  document.addEventListener('fullscreenchange', () => {
621
- if (document.fullscreenElement === img) {
622
  btn.innerHTML = exitIcon;
623
- btn.style.position = 'fixed';
624
- btn.style.zIndex = '2147483647';
 
 
625
  } else {
626
  btn.innerHTML = enterIcon;
627
- btn.style.position = 'absolute';
628
- btn.style.zIndex = '10';
 
 
629
  }
630
  });
631
 
 
297
  def build_street_html(image_url: str) -> str:
298
  base = """
299
  <div id="image-container" style="position:relative;max-width:960px;margin:0 auto;">
300
+ <div id="fullscreen-wrapper" style="position:relative; background-color: #000;">
301
+ <img id="street-image" src="__IMG_URL__" style="width:100%;height:auto;border-radius:8px;box-shadow:0 4px 6px rgba(0,0,0,0.1);display:block;" />
302
+ <button id="fullscreen-btn" title="Toggle Fullscreen" style="position:absolute;top:10px;right:10px;z-index:10;background:rgba(0,0,0,0.5);border:none;color:white;padding:8px;border-radius:4px;cursor:pointer;line-height:0;">
303
+ <!-- SVG icon will be injected by JS -->
304
+ </button>
305
+ </div>
306
  <div id="mini-map-wrap" style="transition:all 0.3s ease;position:absolute;right:10px;bottom:10px;border:2px solid #fff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.2);background:#fff;">
307
  <div id="mini-map" style="width:100%;height:100%;cursor:pointer"></div>
308
  <div id="map-controls" style="position:absolute;right:8px;top:8px;display:flex;gap:6px;z-index:5;">
 
601
  function initFullscreenButtonIfPresent() {
602
  log('initFullscreenButtonIfPresent called');
603
  const btn = document.getElementById('fullscreen-btn');
604
+ const wrapper = document.getElementById('fullscreen-wrapper');
605
  const img = document.getElementById('street-image');
606
+ if (!btn || !wrapper || !img || btn.dataset.initialized === '1') return;
607
 
608
  const enterIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>';
609
  const exitIcon = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0-2-2h-3m-6 0H3a2 2 0 0 0-2 2v3"/></svg>';
610
 
611
  btn.innerHTML = enterIcon;
612
+ const originalImgStyle = {
613
+ width: img.style.width,
614
+ height: img.style.height,
615
+ objectFit: img.style.objectFit,
616
+ borderRadius: img.style.borderRadius,
617
+ };
618
 
619
  btn.addEventListener('click', () => {
620
  if (!document.fullscreenElement) {
621
+ wrapper.requestFullscreen().catch(err => {
622
  log('Fullscreen error:', err);
623
  });
624
  } else {
 
627
  });
628
 
629
  document.addEventListener('fullscreenchange', () => {
630
+ if (document.fullscreenElement === wrapper) {
631
  btn.innerHTML = exitIcon;
632
+ img.style.width = '100%';
633
+ img.style.height = '100%';
634
+ img.style.objectFit = 'contain';
635
+ img.style.borderRadius = '0';
636
  } else {
637
  btn.innerHTML = enterIcon;
638
+ img.style.width = originalImgStyle.width;
639
+ img.style.height = originalImgStyle.height;
640
+ img.style.objectFit = originalImgStyle.objectFit;
641
+ img.style.borderRadius = originalImgStyle.borderRadius;
642
  }
643
  });
644