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>
{% endblock %}
{% 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"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

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