File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121
2222< body onload ="myfunction() ">
2323 < div id ="load "> </ div >
24+
25+ <!-- scrollbar button -->
26+ < div id ="progress ">
27+ < i id ="progress-value " class ="fas fa-arrow-up "> </ i >
28+ </ div >
29+
2430 <!-- Navigation Section -->
2531 < nav >
2632 < div >
Original file line number Diff line number Diff line change @@ -101,3 +101,34 @@ fetch("https://api.github.com/repos/TusharKesarwani/Front-End-Projects/contribut
101101 contributorsList . appendChild ( li ) ;
102102 } ) ;
103103 } ) ;
104+
105+ //-----------for scrollbar button---------------
106+
107+
108+ function calculateScrollValue ( ) {
109+
110+ let scrollProgress = document . getElementById ( 'progress' ) ;
111+ let progressValue = document . getElementById ( 'progress-value' ) ;
112+
113+ let pos = document . documentElement . scrollTop ;
114+ let calcHeight = document . documentElement . scrollHeight - document . documentElement . clientHeight ;
115+
116+ let scrollValue = Math . round ( ( pos * 100 ) / calcHeight ) ;
117+
118+ // for hiding scrollbar button
119+ if ( pos > 100 ) {
120+ scrollProgress . style . display = 'grid' ;
121+ }
122+ else {
123+ scrollProgress . style . display = 'none' ;
124+ }
125+
126+
127+ scrollProgress . addEventListener ( 'click' , ( ) => {
128+ document . documentElement . scrollTop = 0 ;
129+ } )
130+ scrollProgress . style . background = `conic-gradient(#0D4360 ${ scrollValue } %, #d7d7d7 ${ scrollValue } %)` ;
131+
132+ }
133+ window . onscroll = calculateScrollValue ;
134+ window . onload = calculateScrollValue ;
Original file line number Diff line number Diff line change @@ -15,6 +15,31 @@ body {
1515 background-color : white;
1616}
1717
18+ # progress {
19+ cursor : pointer;
20+ position : fixed;
21+ right : 10px ;
22+ bottom : 20px ;
23+ width : 60px ;
24+ height : 60px ;
25+ z-index : 111111 ;
26+ display : none;
27+ place-items : center;
28+ border-radius : 50% ;
29+ box-shadow : 0 0 10px rgba (0 , 0 , 0 , 0.5 );
30+ }
31+ # progress # progress-value {
32+ display : block;
33+ width : calc (100% - 10px );
34+ height : calc (100% - 10px );
35+ background-color : white;
36+ border-radius : 50% ;
37+ display : grid;
38+ place-items : center;
39+ font-size : 25px ;
40+ color : # 001a2e ;
41+ }
42+
1843nav {
1944 display : flex;
2045 justify-content : space-between;
You can’t perform that action at this time.
0 commit comments