Skip to content

Commit f1cfe4c

Browse files
committed
Improved back-to-top button during fast scrolling
1 parent a2ccd73 commit f1cfe4c

File tree

10 files changed

+18
-13
lines changed

10 files changed

+18
-13
lines changed

material/assets/javascripts/bundle.7f366e99.min.js renamed to material/assets/javascripts/bundle.f9fdf24d.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.7f366e99.min.js.map renamed to material/assets/javascripts/bundle.f9fdf24d.min.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.5d38496d.min.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

material/assets/stylesheets/main.ed05e878.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.5d38496d.min.css.map renamed to material/assets/stylesheets/main.ed05e878.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{% endif %}
3535
{% endblock %}
3636
{% block styles %}
37-
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.5d38496d.min.css' | url }}">
37+
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.ed05e878.min.css' | url }}">
3838
{% if config.theme.palette %}
3939
{% set palette = config.theme.palette %}
4040
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.cbb835fc.min.css' | url }}">
@@ -169,7 +169,7 @@
169169
</div>
170170
</div>
171171
{% if "navigation.top" in features %}
172-
<a href="#" class="md-top md-top--hidden md-icon" data-md-component="top">
172+
<a href="#" class="md-top md-icon" data-md-component="top" hidden>
173173
{% include ".icons/material/arrow-up.svg" %}
174174
{{ lang.t('top.title') }}
175175
</a>
@@ -216,7 +216,7 @@
216216
</script>
217217
{% endblock %}
218218
{% block scripts %}
219-
<script src="{{ 'assets/javascripts/bundle.7f366e99.min.js' | url }}"></script>
219+
<script src="{{ 'assets/javascripts/bundle.f9fdf24d.min.js' | url }}"></script>
220220
{% for path in config["extra_javascript"] %}
221221
<script src="{{ path | url }}"></script>
222222
{% endfor %}

src/assets/javascripts/components/top/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function mountBackToTop(
139139

140140
/* Handle emission */
141141
next({ hidden }) {
142-
el.classList.toggle("md-top--hidden", hidden)
142+
el.hidden = hidden
143143
if (hidden) {
144144
el.setAttribute("tabindex", "-1")
145145
el.blur()
@@ -151,7 +151,7 @@ export function mountBackToTop(
151151
/* Handle complete */
152152
complete() {
153153
el.style.top = ""
154-
el.classList.add("md-top--hidden")
154+
el.hidden = true
155155
el.removeAttribute("tabindex")
156156
}
157157
})

src/assets/stylesheets/main/layout/_tabs.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
// Navigation tabs
2828
.md-tabs {
29+
// Must be higher than the z-index of the back-to-top button, or the button
30+
// will overlay the navigation tabs bar when scrolling up fast.
31+
z-index: 3;
2932
width: 100%;
3033
overflow: auto;
3134
color: var(--md-primary-bg-color);

src/assets/stylesheets/main/layout/_top.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
position: fixed;
3030
top: px2rem(48px + 16px);
3131
z-index: 2;
32+
display: block;
3233
margin-inline-start: 50%;
3334
padding: px2rem(8px) px2rem(16px);
3435
color: var(--md-default-fg-color--light);
@@ -55,7 +56,7 @@
5556
}
5657

5758
// Back-to-top button is hidden
58-
&--hidden {
59+
&[hidden] {
5960
transform: translate(-50%, px2rem(4px));
6061
opacity: 0;
6162
transition-duration: 0ms;

src/base.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@
307307
{% if "navigation.top" in features %}
308308
<a
309309
href="#"
310-
class="md-top md-top--hidden md-icon"
310+
class="md-top md-icon"
311311
data-md-component="top"
312+
hidden
312313
>
313314
{% include ".icons/material/arrow-up.svg" %}
314315
{{ lang.t('top.title') }}

0 commit comments

Comments
 (0)