Skip to content

Commit

Permalink
Fixed scroll offset when tabs are brought into view
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Jun 4, 2022
1 parent 35210f5 commit c4cb6b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/base.html
Expand Up @@ -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 %}
Expand Down
12 changes: 8 additions & 4 deletions src/assets/javascripts/components/content/tabs/index.ts
Expand Up @@ -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 */
Expand Down

0 comments on commit c4cb6b4

Please sign in to comment.