Skip to content

Commit ec59dfb

Browse files
authored
Merge pull request #188 from AgainIoT/feature/184
Fix : added offset to the scroll destination
2 parents 89d5aa4 + f46eea3 commit ec59dfb

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/components/main/Welcome.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,21 @@ export const Welcome = () => {
6363
<LearnmoreBtn
6464
variant="contained"
6565
onClick={() => {
66-
document
67-
.querySelector(".STEPS")
68-
.scrollIntoView({ behavior: "smooth" });
66+
const offset = document.querySelector(".header").clientHeight;
67+
window.scrollTo({
68+
behavior: "smooth",
69+
top:
70+
document.querySelector(".STEPS").getBoundingClientRect().top -
71+
document.body.getBoundingClientRect().top -
72+
offset,
73+
});
6974
}}
7075
>
7176
learn more
7277
</LearnmoreBtn>
7378
</Stack>
7479
</InfoDiv>
75-
<ImgDiv {... zoominItem}>
80+
<ImgDiv {...zoominItem}>
7681
<MainImg src={MAIN} />
7782
</ImgDiv>
7883
</StWelcome>

src/layout/Header.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled from "styled-components";
22
import { COLOR } from "../styles/color";
3-
import React, { useState } from "react";
3+
import React, { useRef, useState } from "react";
44
import PropTypes from "prop-types";
55
import { useRecoilState, useSetRecoilState } from "recoil";
66
import { avatar, id, name, isLogin } from "../recoil/authorize";
@@ -58,6 +58,7 @@ export async function checkTokenValid() {
5858
}
5959

6060
export const Header = (props) => {
61+
const headerRef = useRef();
6162
const [anchorElNav, setAnchorElNav] = useState(null);
6263
const [anchorElUser, setAnchorElUser] = useState(null);
6364
const [src, setSrc] = useRecoilState(avatar);
@@ -123,7 +124,7 @@ export const Header = (props) => {
123124
<React.Fragment>
124125
<CssBaseline />
125126
<ElevationScroll {...props}>
126-
<AppBar style={{ background: COLOR.MAIN_WHITE }}>
127+
<AppBar className="header" style={{ background: COLOR.MAIN_WHITE }}>
127128
<Toolbar>
128129
<Box
129130
sx={{

0 commit comments

Comments
 (0)