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';
55import './About.css'
66import marked from "marked" ;
77import codeuino from './codeuino-banner.jpg'
8+ import ScrollToTopBtn from '../../components/ScrollToTopBtn/ScrollToTopBtn.js' ;
89class Blog extends Component {
910 constructor ( props ) {
1011 super ( props ) ;
@@ -57,6 +58,7 @@ class Blog extends Component {
5758 </ div >
5859 </ div >
5960 </ div >
61+ < ScrollToTopBtn />
6062 </ div >
6163 ) ;
6264 }
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import './NewHome.css' ;
3-
3+ import ScrollToTopBtn from '../../components/ScrollToTopBtn/ScrollToTopBtn.js' ;
44import Projects from './Components/Projects'
55import LandingPageComponent from './Components/LandingPageComponent'
66import Activities from './Components/Activities'
@@ -15,6 +15,7 @@ const NewHome = () => {
1515 < Projects />
1616 < Activities />
1717 < Partners />
18+ < ScrollToTopBtn />
1819 </ div >
1920 </ div >
2021 </ div >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
66import './Team.css' ;
77import BoardMembersWrapper from './BoardMembers'
88import CoreContributorsWrapper from './CoreContributors'
9+ import ScrollToTopBtn from '../../components/ScrollToTopBtn/ScrollToTopBtn.js' ;
910import axios from 'axios' ;
1011import $ from 'jquery' ;
1112class Team extends Component {
@@ -63,6 +64,7 @@ class Team extends Component {
6364 </ div >
6465 </ div >
6566 </ div >
67+ < ScrollToTopBtn />
6668 </ >
6769 ) ;
6870 }
You can’t perform that action at this time.
0 commit comments