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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -286,14 +286,15 @@ button {
286
  </script>
287
  """
288
  def app():
289
- with gr.Blocks(css="""
290
- .gradio-column {
291
- min-height: 100vh; /* Ensure each section takes up at least the full viewport height */
292
- display: flex;
293
- flex-direction: column;
294
- justify-content: flex-start; /* Align content to the top */
295
- }
296
- """) as demo:
 
297
  # Login Page
298
  with gr.Column(visible=True) as login_section:
299
  gr.Markdown("# Login Page")
@@ -416,6 +417,20 @@ def app():
416
  lambda: (gr.update(visible=False), gr.update(visible=True)),
417
  outputs=[menu_section, cart_section],
418
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  # Navigate Back to Menu Page
420
  back_to_menu_button.click(
421
  lambda: (gr.update(visible=True), gr.update(visible=False)),
 
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")
 
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)),