Skip to content

Commit

Permalink
Fixed rendering of back-to-top button when used with sticky tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Jul 10, 2021
1 parent 7ca4ca1 commit 7abeb68
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ <h1>{{ page.title | d(config.site_name, true)}}</h1>
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.8400c76f.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.d7b0ad22.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down
10 changes: 6 additions & 4 deletions src/assets/javascripts/components/top/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
setBackToTopOffset,
setBackToTopState
} from "~/actions"
import { Viewport } from "~/browser"
import { Viewport, setElementFocus } from "~/browser"

import { Component } from "../_"
import { Header } from "../header"
Expand Down Expand Up @@ -103,7 +103,7 @@ export function watchBackToTop(
.pipe(
map(({ offset: { y } }) => y),
bufferCount(2, 1),
map(([a, b]) => a > b),
map(([a, b]) => a > b && b),
distinctUntilChanged()
)

Expand Down Expand Up @@ -153,10 +153,12 @@ export function mountBackToTop(
/* Update state */
next([{ hidden }, { height }]) {
setBackToTopOffset(el, height + 16)
if (hidden)
if (hidden) {
setBackToTopState(el, "hidden")
else
setElementFocus(el, false)
} else {
resetBackToTopState(el)
}
},

/* Reset on complete */
Expand Down

0 comments on commit 7abeb68

Please sign in to comment.