File tree Expand file tree Collapse file tree 5 files changed +69
-1
lines changed
components/ScrollToTopBtn Expand file tree Collapse file tree 5 files changed +69
-1
lines changed Original file line number Diff line number Diff line change
1
+ .scroll-to-top {
2
+ position : fixed;
3
+ bottom : 0.5rem ;
4
+ right : 0.5rem ;
5
+ animation : fadeIn 700ms ease-in-out 1s both;
6
+ cursor : pointer;
7
+ z-index : 999 ;
8
+ }
Original file line number Diff line number Diff line change
1
+ import React , { Component } from "react" ;
2
+ import './ScrollToTopBtn.css' ;
3
+
4
+ class ScrollToTopBtn extends Component {
5
+ constructor ( props ) {
6
+ super ( props ) ;
7
+ this . state = {
8
+ is_visible : false
9
+ } ;
10
+ }
11
+
12
+ componentDidMount ( ) {
13
+ var scrollComponent = this ;
14
+ document . addEventListener ( "scroll" , function ( e ) {
15
+ scrollComponent . toggleVisibility ( ) ;
16
+ } ) ;
17
+ }
18
+
19
+ toggleVisibility ( ) {
20
+ if ( window . pageYOffset > 50 ) {
21
+ this . setState ( {
22
+ is_visible : true
23
+ } ) ;
24
+ } else {
25
+ this . setState ( {
26
+ is_visible : false
27
+ } ) ;
28
+ }
29
+ }
30
+
31
+ scrollToTop ( ) {
32
+ window . scrollTo ( {
33
+ top : 0 ,
34
+ behavior : "smooth"
35
+ } ) ;
36
+ }
37
+
38
+ render ( ) {
39
+ const { is_visible } = this . state ;
40
+ return (
41
+ < div className = "scroll-to-top" >
42
+ { is_visible && (
43
+ < div onClick = { ( ) => this . scrollToTop ( ) } >
44
+ < span class = "fa-stack fa-lg" >
45
+ < i class = "fa fa-circle fa-stack-2x" > </ i >
46
+ < i class = "fa fa-arrow-up fa-stack-1x fa-inverse" aria-hidden = "true" > </ i >
47
+ </ span >
48
+ </ div >
49
+ ) }
50
+ </ div >
51
+ ) ;
52
+ }
53
+ }
54
+
55
+ export default ScrollToTopBtn ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Markdown from 'react-markdown';
5
5
import './About.css'
6
6
import marked from "marked" ;
7
7
import codeuino from './codeuino-banner.jpg'
8
+ import ScrollToTopBtn from '../../components/ScrollToTopBtn/ScrollToTopBtn.js' ;
8
9
class Blog extends Component {
9
10
constructor ( props ) {
10
11
super ( props ) ;
@@ -57,6 +58,7 @@ class Blog extends Component {
57
58
</ div >
58
59
</ div >
59
60
</ div >
61
+ < ScrollToTopBtn />
60
62
</ div >
61
63
) ;
62
64
}
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import './NewHome.css' ;
3
-
3
+ import ScrollToTopBtn from '../../components/ScrollToTopBtn/ScrollToTopBtn.js' ;
4
4
import Projects from './Components/Projects'
5
5
import LandingPageComponent from './Components/LandingPageComponent'
6
6
import Activities from './Components/Activities'
@@ -15,6 +15,7 @@ const NewHome = () => {
15
15
< Projects />
16
16
< Activities />
17
17
< Partners />
18
+ < ScrollToTopBtn />
18
19
</ div >
19
20
</ div >
20
21
</ div >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
import './Team.css' ;
7
7
import BoardMembersWrapper from './BoardMembers'
8
8
import CoreContributorsWrapper from './CoreContributors'
9
+ import ScrollToTopBtn from '../../components/ScrollToTopBtn/ScrollToTopBtn.js' ;
9
10
import axios from 'axios' ;
10
11
import $ from 'jquery' ;
11
12
class Team extends Component {
@@ -63,6 +64,7 @@ class Team extends Component {
63
64
</ div >
64
65
</ div >
65
66
</ div >
67
+ < ScrollToTopBtn />
66
68
</ >
67
69
) ;
68
70
}
You canβt perform that action at this time.
0 commit comments