Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,6 +78,14 @@ def filter_menu(preference):
|
|
| 78 |
"""
|
| 79 |
return html_content
|
| 80 |
# Preserving your JavaScript for modal and cart functionality (Your original JavaScript logic)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
modal_and_cart_js = """
|
| 82 |
<style>
|
| 83 |
.cart-container {
|
|
@@ -443,19 +451,19 @@ def app():
|
|
| 443 |
# Navigate to Cart Page (Both Buttons Use the Same Logic)
|
| 444 |
# Top View Cart Button
|
| 445 |
view_cart_button_top.click(
|
| 446 |
-
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
| 447 |
-
outputs=[menu_section, cart_section],
|
| 448 |
-
_js="() => window.scrollTo({top: 0, behavior: 'smooth'})"
|
| 449 |
)
|
| 450 |
|
|
|
|
| 451 |
# Bottom View Cart Button
|
| 452 |
view_cart_button_bottom.click(
|
| 453 |
-
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
| 454 |
-
outputs=[menu_section, cart_section],
|
| 455 |
-
_js="() => window.scrollTo({top: 0, behavior: 'smooth'})"
|
| 456 |
)
|
| 457 |
|
| 458 |
|
|
|
|
| 459 |
# Navigate Back to Menu Page
|
| 460 |
back_to_menu_button.click(
|
| 461 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
|
|
|
| 78 |
"""
|
| 79 |
return html_content
|
| 80 |
# Preserving your JavaScript for modal and cart functionality (Your original JavaScript logic)
|
| 81 |
+
scroll_js = """
|
| 82 |
+
<script>
|
| 83 |
+
function scrollToTop() {
|
| 84 |
+
window.scrollTo({top: 0, behavior: 'smooth'});
|
| 85 |
+
}
|
| 86 |
+
</script>
|
| 87 |
+
"""
|
| 88 |
+
|
| 89 |
modal_and_cart_js = """
|
| 90 |
<style>
|
| 91 |
.cart-container {
|
|
|
|
| 451 |
# Navigate to Cart Page (Both Buttons Use the Same Logic)
|
| 452 |
# Top View Cart Button
|
| 453 |
view_cart_button_top.click(
|
| 454 |
+
lambda: (gr.update(visible=False), gr.update(visible=True), "<script>scrollToTop();</script>"),
|
| 455 |
+
outputs=[menu_section, cart_section, scroll_trigger],
|
|
|
|
| 456 |
)
|
| 457 |
|
| 458 |
+
|
| 459 |
# Bottom View Cart Button
|
| 460 |
view_cart_button_bottom.click(
|
| 461 |
+
lambda: (gr.update(visible=False), gr.update(visible=True), "<script>scrollToTop();</script>"),
|
| 462 |
+
outputs=[menu_section, cart_section, scroll_trigger],
|
|
|
|
| 463 |
)
|
| 464 |
|
| 465 |
|
| 466 |
+
|
| 467 |
# Navigate Back to Menu Page
|
| 468 |
back_to_menu_button.click(
|
| 469 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|