Rammohan0504 commited on
Commit
e254cb9
·
verified ·
1 Parent(s): 4bafc13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -107,7 +107,7 @@ with gr.Blocks() as demo:
107
  btn_halal.click(lambda: display_dishes("HALAL"), outputs=[menu_html])
108
 
109
  gr.HTML("""
110
- <div id="popup" style="display: none; position: fixed; left: 50%; transform: translateX(-50%);
111
  background-color: white; padding: 20px; border-radius: 10px;
112
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
113
  <div style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; font-weight: bold;" onclick="closePopup()">&times;</div>
@@ -117,19 +117,22 @@ with gr.Blocks() as demo:
117
  <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px;">Close</button>
118
  </div>
119
  <script>
120
- function showPopup(title, description, price) {
121
  const popup = document.getElementById('popup');
122
  document.getElementById('popup-title').textContent = title;
123
  document.getElementById('popup-description').textContent = description;
124
  document.getElementById('popup-price').textContent = price;
125
- popup.style.top = `${window.scrollY + 100}px`; // Adjust based on scroll position
126
- popup.style.display = 'block'; // Make the popup visible
127
- }
128
 
129
- function closePopup() {
 
 
 
 
 
 
130
  const popup = document.getElementById('popup');
131
  popup.style.display = 'none'; // Hide the popup
132
- }
133
  </script>
134
  """)
135
 
 
107
  btn_halal.click(lambda: display_dishes("HALAL"), outputs=[menu_html])
108
 
109
  gr.HTML("""
110
+ <div id="popup" style="display: none; position: absolute; left: 50%; transform: translateX(-50%);
111
  background-color: white; padding: 20px; border-radius: 10px;
112
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
113
  <div style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; font-weight: bold;" onclick="closePopup()">&times;</div>
 
117
  <button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px;">Close</button>
118
  </div>
119
  <script>
120
+ function showPopup(title, description, price) {{
121
  const popup = document.getElementById('popup');
122
  document.getElementById('popup-title').textContent = title;
123
  document.getElementById('popup-description').textContent = description;
124
  document.getElementById('popup-price').textContent = price;
 
 
 
125
 
126
+ // Adjust position based on scroll
127
+ const scrollY = window.scrollY;
128
+ popup.style.top = `${{scrollY + 200}}px`; // Dynamically position 200px below the scroll position
129
+ popup.style.display = 'block'; // Show the popup
130
+ }}
131
+
132
+ function closePopup() {{
133
  const popup = document.getElementById('popup');
134
  popup.style.display = 'none'; // Hide the popup
135
+ }}
136
  </script>
137
  """)
138