SideChat.js
942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import './App.css';
import axios from "axios";
import { useEffect } from 'react';
import './SideChat.css'
const scrollChat = () => {
let scrollY;
const sideChat = document.getElementsByClassName('SideChat')[0];
scrollY = window.scrollY + window.outerHeight / 2;
sideChat.style.top = scrollY +"px";
document.addEventListener('scroll', ()=>{
sideChat.style.transition = '800ms';
scrollY = window.scrollY + window.outerHeight / 2;
sideChat.style.top = scrollY +"px";
});
}
function SideChat() {
const callApi = async()=>{
axios.get("/api").then((res)=>{console.log(res.data.test)});
};
useEffect(()=>{
callApi();
scrollChat();
}, []);
return (
<div>
<div className='SideChat' height="100px" width="100px" style={{background:"gray"}}>
하이
</div>
<div className='scrollmake'>
바보
</div>
</div>
);
}
export default SideChat;