Tas01 commited on
Commit
85544ec
·
verified ·
1 Parent(s): 4d4ee4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -39
app.py CHANGED
@@ -470,50 +470,71 @@ with gr.Blocks(title="CLIP-ViT Image Analyzer", theme=gr.themes.Soft()) as demo:
470
  """
471
 
472
  # Add this JavaScript separately
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  javascript = """
474
  <script>
475
  document.addEventListener('DOMContentLoaded', function() {
476
- // Force container height immediately
477
- const forceHeight = function() {
478
- const containers = document.querySelectorAll('.gradio-container, .container, #blocks-container');
479
- containers.forEach(container => {
480
- container.style.height = '100vh';
481
- container.style.maxHeight = '100vh';
 
 
 
482
  container.style.overflowY = 'auto';
483
- });
484
- };
485
-
486
- // Run immediately
487
- forceHeight();
488
-
489
- // Run again after a short delay to catch dynamic content
490
- setTimeout(forceHeight, 100);
491
- setTimeout(forceHeight, 500);
492
-
493
- // Monitor for ANY DOM changes
494
- const observer = new MutationObserver(function(mutations) {
495
- forceHeight();
496
- // Constrain any new elements
497
- mutations.forEach(function(mutation) {
498
- mutation.addedNodes.forEach(function(node) {
499
- if (node.nodeType === 1) {
500
- node.style.maxHeight = '100%';
501
- if (node.querySelectorAll) {
502
- node.querySelectorAll('*').forEach(child => {
503
- child.style.maxHeight = '100%';
504
- });
505
- }
506
- }
507
- });
508
- });
509
- });
510
-
511
- observer.observe(document.body, {
512
- childList: true,
513
- subtree: true,
514
- attributes: true,
515
- attributeFilter: ['style', 'class']
516
  });
 
 
 
 
517
  });
518
  </script>
519
  """
 
470
  """
471
 
472
  # Add this JavaScript separately
473
+ # javascript = """
474
+ # <script>
475
+ # document.addEventListener('DOMContentLoaded', function() {
476
+ # // Force container height immediately
477
+ # const forceHeight = function() {
478
+ # const containers = document.querySelectorAll('.gradio-container, .container, #blocks-container');
479
+ # containers.forEach(container => {
480
+ # container.style.height = '100vh';
481
+ # container.style.maxHeight = '100vh';
482
+ # container.style.overflowY = 'auto';
483
+ # });
484
+ # };
485
+
486
+ # // Run immediately
487
+ # forceHeight();
488
+
489
+ # // Run again after a short delay to catch dynamic content
490
+ # setTimeout(forceHeight, 100);
491
+ # setTimeout(forceHeight, 500);
492
+
493
+ # // Monitor for ANY DOM changes
494
+ # const observer = new MutationObserver(function(mutations) {
495
+ # forceHeight();
496
+ # // Constrain any new elements
497
+ # mutations.forEach(function(mutation) {
498
+ # mutation.addedNodes.forEach(function(node) {
499
+ # if (node.nodeType === 1) {
500
+ # node.style.maxHeight = '100%';
501
+ # if (node.querySelectorAll) {
502
+ # node.querySelectorAll('*').forEach(child => {
503
+ # child.style.maxHeight = '100%';
504
+ # });
505
+ # }
506
+ # }
507
+ # });
508
+ # });
509
+ # });
510
+
511
+ # observer.observe(document.body, {
512
+ # childList: true,
513
+ # subtree: true,
514
+ # attributes: true,
515
+ # attributeFilter: ['style', 'class']
516
+ # });
517
+ # });
518
+ # </script>
519
  javascript = """
520
  <script>
521
  document.addEventListener('DOMContentLoaded', function() {
522
+ const stopExpansion = function() {
523
+ // More aggressive containment
524
+ document.body.style.maxHeight = '100vh';
525
+ document.body.style.overflow = 'hidden';
526
+
527
+ const containers = document.querySelectorAll('div');
528
+ containers.forEach(container => {
529
+ if (container.scrollHeight > window.innerHeight) {
530
+ container.style.maxHeight = '95vh';
531
  container.style.overflowY = 'auto';
532
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
  });
534
+ };
535
+
536
+ stopExpansion();
537
+ setInterval(stopExpansion, 1000); // Keep checking every second
538
  });
539
  </script>
540
  """