nagasurendra commited on
Commit
8b2439a
·
verified ·
1 Parent(s): a108d8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -300,6 +300,27 @@ button {
300
  }
301
  });
302
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
  """
305
  # Authentication and Navigation Logic
 
300
  }
301
  });
302
  </script>
303
+ <script>
304
+ document.addEventListener("DOMContentLoaded", function () {
305
+ // Attach a click event listener to the View Cart button
306
+ const observer = new MutationObserver(() => {
307
+ const viewCartButton = document.querySelector("button:contains('View Cart')");
308
+ if (viewCartButton) {
309
+ viewCartButton.addEventListener("click", function () {
310
+ // Scroll to the top of the page
311
+ setTimeout(() => {
312
+ window.scrollTo({ top: 0, behavior: 'smooth' });
313
+ }, 100); // Slight delay to ensure page updates before scrolling
314
+ });
315
+ observer.disconnect(); // Stop observing once the button is found
316
+ }
317
+ });
318
+
319
+ // Observe the Gradio container for dynamically loaded elements
320
+ observer.observe(document.body, { childList: true, subtree: true });
321
+ });
322
+ </script>
323
+
324
 
325
  """
326
  # Authentication and Navigation Logic