Showing
4 changed files
with
72 additions
and
4 deletions
client/src/Component/SideChat.css
0 → 100644
1 | +.SideChat { | ||
2 | + color: yellow; | ||
3 | + background-color: gray; | ||
4 | + position: absolute; | ||
5 | + z-index: 999; | ||
6 | + right:100px; | ||
7 | + top:0px; | ||
8 | + transition: 0ms; | ||
9 | +} | ||
10 | + | ||
11 | +.scrollmake{ | ||
12 | + height:1200px; | ||
13 | + width:100px; | ||
14 | + background-color: red; | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
client/src/Component/SideChat.js
0 → 100644
1 | +import './App.css'; | ||
2 | +import axios from "axios"; | ||
3 | +import { useEffect } from 'react'; | ||
4 | +import './SideChat.css' | ||
5 | + | ||
6 | +const scrollChat = () => { | ||
7 | + let scrollY; | ||
8 | + | ||
9 | + const sideChat = document.getElementsByClassName('SideChat')[0]; | ||
10 | + | ||
11 | + scrollY = window.scrollY + window.outerHeight / 2; | ||
12 | + sideChat.style.top = scrollY +"px"; | ||
13 | + | ||
14 | + document.addEventListener('scroll', ()=>{ | ||
15 | + sideChat.style.transition = '800ms'; | ||
16 | + scrollY = window.scrollY + window.outerHeight / 2; | ||
17 | + sideChat.style.top = scrollY +"px"; | ||
18 | + | ||
19 | + }); | ||
20 | + | ||
21 | + | ||
22 | +} | ||
23 | + | ||
24 | +function SideChat() { | ||
25 | + const callApi = async()=>{ | ||
26 | + axios.get("/api").then((res)=>{console.log(res.data.test)}); | ||
27 | + }; | ||
28 | + | ||
29 | + useEffect(()=>{ | ||
30 | + callApi(); | ||
31 | + scrollChat(); | ||
32 | + }, []); | ||
33 | + | ||
34 | + return ( | ||
35 | + <div> | ||
36 | + <div className='SideChat' height="100px" width="100px" style={{background:"gray"}}> | ||
37 | + 하이 | ||
38 | + | ||
39 | + </div> | ||
40 | + | ||
41 | + | ||
42 | + <div className='scrollmake'> | ||
43 | + 바보 | ||
44 | + </div> | ||
45 | + </div> | ||
46 | + ); | ||
47 | +} | ||
48 | + | ||
49 | +export default SideChat; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -4,7 +4,7 @@ import { useEffect } from 'react'; | ... | @@ -4,7 +4,7 @@ import { useEffect } from 'react'; |
4 | import { Navbar, Container, NavDropdown, Nav} from 'react-bootstrap' | 4 | import { Navbar, Container, NavDropdown, Nav} from 'react-bootstrap' |
5 | import khuimg from '../img/khumeal.png' | 5 | import khuimg from '../img/khumeal.png' |
6 | 6 | ||
7 | -function App() { | 7 | +function TopBanner() { |
8 | const callApi = async()=>{ | 8 | const callApi = async()=>{ |
9 | axios.get("/api").then((res)=>{console.log(res.data.test)}); | 9 | axios.get("/api").then((res)=>{console.log(res.data.test)}); |
10 | }; | 10 | }; |
... | @@ -32,4 +32,4 @@ function App() { | ... | @@ -32,4 +32,4 @@ function App() { |
32 | ); | 32 | ); |
33 | } | 33 | } |
34 | 34 | ||
35 | -export default App; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
35 | +export default TopBanner; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | import React from 'react'; | 1 | import React from 'react'; |
2 | import ReactDOM from 'react-dom/client'; | 2 | import ReactDOM from 'react-dom/client'; |
3 | import './index.css'; | 3 | import './index.css'; |
4 | -import App from './Component/App'; | 4 | +import TopBanner from './Component/TopBanner'; |
5 | +import SideChat from './Component/SideChat'; | ||
5 | import reportWebVitals from './reportWebVitals'; | 6 | import reportWebVitals from './reportWebVitals'; |
6 | import 'bootstrap/dist/css/bootstrap.min.css'; | 7 | import 'bootstrap/dist/css/bootstrap.min.css'; |
7 | 8 | ||
8 | const root = ReactDOM.createRoot(document.getElementById('root')); | 9 | const root = ReactDOM.createRoot(document.getElementById('root')); |
9 | root.render( | 10 | root.render( |
10 | <React.StrictMode> | 11 | <React.StrictMode> |
11 | - <App /> | 12 | + <div className='Screen' style={{width: '100vw', height:'100vh' }}> |
13 | + <TopBanner /> | ||
14 | + <SideChat /> | ||
15 | + </div> | ||
12 | </React.StrictMode> | 16 | </React.StrictMode> |
13 | ); | 17 | ); |
14 | 18 | ... | ... |
-
Please register or login to post a comment