Fixed scroll offset when tabs are brought into view

This commit is contained in:
squidfunk 2022-06-04 08:52:34 +02:00
parent 35210f560f
commit c4cb6b45a3
4 changed files with 13 additions and 9 deletions

View File

@ -216,7 +216,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.0f659f14.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.7f366e99.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %} {% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>
{% endfor %} {% endfor %}

View File

@ -140,10 +140,14 @@ export function mountContentTabs(
/* Scroll container to active content tab */ /* Scroll container to active content tab */
const content = getElementContentOffset(container) const content = getElementContentOffset(container)
if (offset.x < content.x) if (
prev.click() offset.x < content.x ||
else if (offset.x + width > content.x + size.width) offset.x + width > content.x + size.width
next.click() )
container.scrollTo({
left: Math.max(0, offset.x - 16),
behavior: "smooth"
})
}, },
/* Handle complete */ /* Handle complete */