nagasurendra commited on
Commit
5520b97
·
verified ·
1 Parent(s): 90e07ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -24
app.py CHANGED
@@ -286,15 +286,12 @@ button {
286
  </script>
287
  """
288
  def app():
289
- with gr.Blocks() as demo:
290
- gr.HTML("""
291
- <script>
292
- function scrollToTop() {
293
- window.scrollTo(0, 0); // Reset the scroll position to the top of the page
294
- }
295
- </script>
296
- """)
297
-
298
  # Login Page
299
  with gr.Column(visible=True) as login_section:
300
  gr.Markdown("# Login Page")
@@ -374,7 +371,7 @@ def app():
374
  gr.HTML(modal_and_cart_js)
375
 
376
  # Cart & Final Order Page
377
- with gr.Column(visible=False) as cart_section:
378
  gr.Markdown("### Cart & Final Order Page")
379
 
380
  # Floating cart display
@@ -417,20 +414,6 @@ def app():
417
  lambda: (gr.update(visible=False), gr.update(visible=True)),
418
  outputs=[menu_section, cart_section],
419
  )
420
- # Inject Scroll-to-Top Trigger
421
- gr.HTML("""
422
- <script>
423
- // Listen for view cart button click and reset scroll position
424
- const viewCartButton = document.querySelector('button:contains("View Cart")');
425
- if (viewCartButton) {
426
- viewCartButton.addEventListener("click", () => {
427
- setTimeout(() => {
428
- scrollToTop(); // Reset scroll position when transitioning to Cart Page
429
- }, 100); // Ensure transition happens before scrolling
430
- });
431
- }
432
- </script>
433
- """)
434
  # Navigate Back to Menu Page
435
  back_to_menu_button.click(
436
  lambda: (gr.update(visible=True), gr.update(visible=False)),
 
286
  </script>
287
  """
288
  def app():
289
+ with gr.Blocks(css="""
290
+ #cart-section {
291
+ height: 760px; /* Fixed height for the Cart Page */
292
+ overflow-y: auto; /* Enable scrolling if content exceeds height */
293
+ }
294
+ """) as demo:
 
 
 
295
  # Login Page
296
  with gr.Column(visible=True) as login_section:
297
  gr.Markdown("# Login Page")
 
371
  gr.HTML(modal_and_cart_js)
372
 
373
  # Cart & Final Order Page
374
+ with gr.Column(visible=False, elem_id="cart-section") as cart_section:
375
  gr.Markdown("### Cart & Final Order Page")
376
 
377
  # Floating cart display
 
414
  lambda: (gr.update(visible=False), gr.update(visible=True)),
415
  outputs=[menu_section, cart_section],
416
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  # Navigate Back to Menu Page
418
  back_to_menu_button.click(
419
  lambda: (gr.update(visible=True), gr.update(visible=False)),