Skip to content

Commit

Permalink
added scroll to top
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush4345 committed Mar 1, 2024
1 parent a9723b9 commit 9176ebc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/ProjectsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const ProjectsPage = ({ projects }) => {
setCurrentPage(data.selected);
};

useEffect(() => {
window.scrollTo(0, 0);
}, [currentPage]);

const indexOfLastProject = (currentPage + 1) * projectsPerPage;
const indexOfFirstProject = indexOfLastProject - projectsPerPage;
const currentProjects = projects.slice(indexOfFirstProject, indexOfLastProject);
Expand Down
5 changes: 5 additions & 0 deletions src/components/blog/blogList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const BlogList = () => {
const currentBlogs = blogs.slice(indexOfFirstProject, indexOfLastProject);
const pageCount = Math.ceil(blogs.length / blogsPerPage);

useEffect(() => {
window.scrollTo(0, 0);
}, [currentPage]);


return (
<>
<div className='mt-20 min-h-[90vh] relative'>
Expand Down
4 changes: 4 additions & 0 deletions src/components/event/eventList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const EventList = () => {
setCurrentPage(data.selected);
};

useEffect(() => {
window.scrollTo(0, 0);
}, [currentPage]);

return (
<>
<div className='mt-20 min-h-[90vh] relative'>
Expand Down

0 comments on commit 9176ebc

Please sign in to comment.