From 5d28e5a95912ad9a85420be28d14394010a67558 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 9 Nov 2023 10:05:02 +0100 Subject: [PATCH] Add autoscroll to widget after changing pages (Z#23135651) (#3698) * Add autoscroll to widget after changing pages * revert add autoscroll to widget * add watcher on root.view * check if scrollIntoView is necessary --------- Co-authored-by: Richard Schreiber --- .../static/pretixpresale/js/widget/widget.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index 9d73f8894..ddd680b53 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -2005,7 +2005,19 @@ var create_widget = function (element) { observer.observe(this.$el, observerOptions); }, computed: shared_root_computed, - methods: shared_root_methods + methods: shared_root_methods, + watch: { + 'view': function (newValue, oldValue) { + if (oldValue) { + // always make sure the widget is scrolled to the top + // as we only check top, we do not need to wait for a redraw + var rect = this.$el.getBoundingClientRect(); + if (rect.top < 0) { + this.$el.scrollIntoView(); + } + } + } + } }); create_overlay(app); return app;