nagasurendra commited on
Commit
42403a5
·
verified ·
1 Parent(s): a31381c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -135,15 +135,14 @@ modal_and_cart_js = """
135
  }
136
  const modal = document.getElementById('modal');
137
  modal.style.display = 'block';
138
- modal.style.position = 'absolute';
139
  if (window.innerWidth <= 768) {
140
  modal.style.width = '90%';
 
141
  } else {
142
  modal.style.width = '30%';
 
143
  }
144
- const currentTop = parseInt(window.getComputedStyle(modal).top, 10);
145
- const newTop = currentTop + 15;
146
- modal.style.top = `${newTop}px`;
147
  modal.style.left = '50%';
148
  modal.style.transform = 'translate(-50%, -50%)';
149
  document.getElementById('modal-image').src = image;
@@ -322,7 +321,7 @@ def app():
322
 
323
  # Modal window
324
  modal_window = gr.HTML("""
325
- <div id="modal" style="display: none; position: absolute; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
326
  <div style="text-align: right;">
327
  <button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">&times;</button>
328
  </div>
 
135
  }
136
  const modal = document.getElementById('modal');
137
  modal.style.display = 'block';
138
+ modal.style.position = 'fixed';
139
  if (window.innerWidth <= 768) {
140
  modal.style.width = '90%';
141
+ modal.style.top = `${event.touches ? event.touches[0].screenY : event.clientY}px`;
142
  } else {
143
  modal.style.width = '30%';
144
+ modal.style.top = `${event.clientY}px`; // Use mouse Y position for laptop
145
  }
 
 
 
146
  modal.style.left = '50%';
147
  modal.style.transform = 'translate(-50%, -50%)';
148
  document.getElementById('modal-image').src = image;
 
321
 
322
  # Modal window
323
  modal_window = gr.HTML("""
324
+ <div id="modal" style="display: none; position: fixed; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
325
  <div style="text-align: right;">
326
  <button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">&times;</button>
327
  </div>