diff --git a/funwithphysics/src/Components/Home/Home.css b/funwithphysics/src/Components/Home/Home.css index f83d90d57..80cb6c0ba 100644 --- a/funwithphysics/src/Components/Home/Home.css +++ b/funwithphysics/src/Components/Home/Home.css @@ -395,3 +395,8 @@ h2 { width: 10%; border: 0.2px solid red; } + +.flexMe{ + display: flex; + justify-content: center; +} \ No newline at end of file diff --git a/funwithphysics/src/Components/Home/Home.js b/funwithphysics/src/Components/Home/Home.js index 218557b8b..67c1dc060 100644 --- a/funwithphysics/src/Components/Home/Home.js +++ b/funwithphysics/src/Components/Home/Home.js @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useState } from "react"; +import React, { useContext, useEffect, useState,useRef } from "react"; import "../Home/Home.css"; import { Button } from "react-bootstrap"; import Footer from "../Footer/Footer"; @@ -8,6 +8,8 @@ import Navbar from "../Navbar/Navbar"; import { Context } from "../../App"; const Home = () => { + + const backToTopRef=useRef(null) const [loading, setloading] = useState(true); const { dispatch } = useContext(Context); useEffect(() => { @@ -29,36 +31,55 @@ const bookReaderStyle = { margin: "0", paddingRight: "9px", }; + + //back to top functionality + const handleScroll = () => { + const position = window.pageYOffset + //console.log(position) + if (position == 0) + backToTopRef.current.style.display = 'none' + else backToTopRef.current.style.display = 'block' + } + + useEffect(() => { + window.addEventListener('scroll', handleScroll, { passive: true }) + + return () => { + window.removeEventListener('scroll', handleScroll) + } + }, []) + + return ( Fun With Science - Tech N Science {/* ----Banner---- */} -
-

- Photo by{" "} - +

+

+ Photo by{' '} + NASA - {" "} - on{" "} - + {' '} + on{' '} + Unsplash

-
-
-

+
+
+

We at Tech N Science try to bring all sciences under one roof by providing JEE level questions and also calculators for different science formulas. @@ -66,34 +87,40 @@ const bookReaderStyle = { So, keep Exploring!!.

-
-

-

+

Learn

-
+