File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ < button class ="arrow-for-scrolling-top " id ="js-scroll-top ">
2+ {% octicon "chevron-up" %}
3+ </ button >
Original file line number Diff line number Diff line change 22import '../stylesheets/index.scss'
33import displayPlatformSpecificContent from './display-platform-specific-content'
44import explorer from './explorer'
5+ import scrollUp from './scroll-up'
56import search from './search'
67import nav from './nav'
78import browserDateFormatter from 'browser-date-formatter'
@@ -23,6 +24,7 @@ import airgapLinks from './airgap-links'
2324document . addEventListener ( 'DOMContentLoaded' , async ( ) => {
2425 displayPlatformSpecificContent ( )
2526 explorer ( )
27+ scrollUp ( )
2628 search ( )
2729 nav ( )
2830 browserDateFormatter ( )
Original file line number Diff line number Diff line change 1+ export default function ( ) {
2+ // function to scroll up to page top
3+ const PageTopBtn = document . getElementById ( 'js-scroll-top' )
4+ if ( ! PageTopBtn ) return
5+
6+ PageTopBtn . addEventListener ( 'click' , ( e ) => {
7+ window . scrollTo ( {
8+ top : 0 ,
9+ behavior : 'smooth'
10+ } )
11+ } )
12+
13+ // show scroll button only when display is scroll down
14+ window . addEventListener ( 'scroll' , function ( ) {
15+ const y = document . documentElement . scrollTop // get the height from page top
16+ if ( y < 100 ) {
17+ PageTopBtn . classList . remove ( 'show' )
18+ } else if ( y >= 100 ) {
19+ PageTopBtn . classList . add ( 'show' )
20+ }
21+ } )
22+ }
Original file line number Diff line number Diff line change 1515 {% endif %}
1616 {% include support-section %}
1717 {% include small-footer %}
18+ {% include scroll-button %}
1819 </ main >
1920 </ body >
2021</ html >
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ $marketing-font-path: "/dist/fonts/";
4747@import " search.scss" ;
4848@import " overrides.scss" ;
4949@import " sidebar.scss" ;
50+ @import " scroll-button.scss" ;
5051@import " explorer.scss" ;
5152// from https://unpkg.com/highlight.js@9.15.8/styles/github.css
5253@import " syntax-highlighting.scss" ;
Original file line number Diff line number Diff line change 1+ button .arrow-for-scrolling-top {
2+ opacity : 0 ;
3+ transition : 1s ;
4+ background-color : #0367d6 ;
5+ color : #fff ;
6+ position : fixed ;
7+ bottom : 10px ;
8+ right : 10px ;
9+ display : block ;
10+ width : 40px ;
11+ height : 40px ;
12+ border-radius : 50% ;
13+ & .show {
14+ opacity : 1 ;
15+ border : none ;
16+ transition : 1s ;
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments