-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrh-back-to-top.html
48 lines (42 loc) · 1.17 KB
/
rh-back-to-top.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<div id="overflow">
<a id="top" href="#bottom">Go to bottom</a>
<p>Scroll down or press tab to see the back to top button</p>
<a id="bottom" href="#top">Go to top</a>
<rh-back-to-top href="#top">Back to top</rh-back-to-top>
</div>
<script type="module">
import '@rhds/elements/rh-back-to-top/rh-back-to-top.js';
import '@patternfly/elements/pf-icon/pf-icon.js';
</script>
<style>
main {
display: block;
scroll-behavior: smooth;
max-height: calc(100dvh - var(--pf-demo-header-height)) !important;
}
#nav {
height: calc(100dvh - var(--pf-demo-header-height, 4.375rem)) !important;
}
#overflow {
min-height: calc(100dvh + 401px);
position: relative;
}
#bottom {
position: absolute;
bottom: 0;
}
@media (prefers-reduced-motion: reduce) {
main {
scroll-behavior: auto;
}
}
</style>
<script type="module">
/* add support for demo/fullscreen and dev server */
const b2t = document.querySelector('rh-back-to-top');
const main = document.querySelector('main');
// if main isn't scrollable use window
if (window.getComputedStyle(main).overflow === 'scroll') {
b2t.scrollableSelector = 'main';
}
</script>