Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최은석
/
ossw-project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최은석
2022-06-03 20:14:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ffd60628cfe634884687ea2e74ea31329c082380
ffd60628
1 parent
0dbf802c
connect side chat to back
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
24 deletions
client/src/Component/InnerChat.js
client/src/Component/SideChat.css
client/src/Component/SideChat.js
client/src/Component/InnerChat.js
0 → 100644
View file @
ffd6062
import
React
,
{
Component
}
from
'react'
;
function
InnerChat
(
props
)
{
return
(
<
div
>
<
div
style
=
{{
fontSize
:
20
,
borderWidth
:
0
}}
>
{
props
.
value
}
<
/div
>
<
div
style
=
{{
color
:
'gray'
,
textAlign
:
'right'
,
borderWidth
:
0
}}
>
{
props
.
time
}
<
/div
>
<
/div
>
);
}
export
default
InnerChat
;
client/src/Component/SideChat.css
View file @
ffd6062
...
...
@@ -40,6 +40,7 @@
width
:
87%
;
height
:
90%
;
margin-top
:
3%
;
overflow
:
scroll
;
vertical-align
:
bottom
;
}
...
...
client/src/Component/SideChat.js
View file @
ffd6062
import
'./App.css'
;
import
axios
from
"axios"
;
import
{
useEffect
}
from
'react'
;
import
{
useEffect
,
useState
,
useRef
}
from
'react'
;
import
'./SideChat.css'
import
InnerChat
from
'./InnerChat'
;
function
SideChat
()
{
const
callApi
=
async
()
=>
{
axios
.
get
(
"/api"
).
then
((
res
)
=>
{
console
.
log
(
res
.
data
.
test
)});
const
chatContainer
=
useRef
(
null
);
const
[
list
,
setList
]
=
useState
([]);
const
getWaiting
=
()
=>
{
axios
.
get
(
"/api/waiting"
).
then
((
res
)
=>
{
setList
(
res
.
data
);
setTimeout
(()
=>
{
const
scroll
=
chatContainer
.
current
.
scrollHeight
-
chatContainer
.
current
.
clientHeight
;
chatContainer
.
current
.
scrollTo
(
0
,
scroll
);
},
100
);
});
}
};
const
postWaiting
=
(
inp
)
=>
{
axios
.
post
(
"/api/waiting"
,
{
value
:
inp
}).
then
((
res
)
=>
{
getWaiting
();
});
}
useEffect
(()
=>
{
callApi
();
//addChat();
useEffect
(()
=>
{
getWaiting
();
scrollChat
();
},
[]);
return
(
<
div
className
=
'SideChat'
>
<
div
className
=
'innerChat1'
>
<
div
ref
=
{
chatContainer
}
className
=
'innerChat1'
>
{
list
.
map
(
waiting
=>
{
return
(
<
div
>
<
InnerChat
value
=
{
waiting
.
value
}
time
=
{
waiting
.
time
}
/
>
<
/div
>
)
})}
<
/div
>
<
div
className
=
'innerChat2'
>
<
div
>
대기시간
<
/div
>
<
div
className
=
'innerBtnCover'
>
<
button
className
=
'innerBtn'
id
=
'under5'
>
5
분
이내
<
/button
>
<
button
className
=
'innerBtn'
id
=
'5to10'
>
5
분
~
10
분
<
/button
>
<
button
className
=
'innerBtn'
id
=
'over10'
>
10
분
이상
<
/button
>
<
button
className
=
'innerBtn'
id
=
'under5'
onClick
=
{()
=>
postWaiting
(
"5분 이내"
)}
>
5
분
이내
<
/button
>
<
button
className
=
'innerBtn'
id
=
'5to10'
onClick
=
{()
=>
postWaiting
(
"5분~10분"
)}
>
5
분
~
10
분
<
/button
>
<
button
className
=
'innerBtn'
id
=
'over10'
onClick
=
{()
=>
postWaiting
(
"10분 이상"
)}
>
10
분
이상
<
/button
>
<
/div
>
<
/div
>
<
/div
>
...
...
@@ -37,25 +55,18 @@ function SideChat() {
);
}
// <div className='scrollmake' style={{height:'1200px', width:'100px',backgroundColor:'red' }}>
// 바보
// </div>
const
scrollChat
=
()
=>
{
let
scrollY
;
const
sideChat
=
document
.
getElementsByClassName
(
'SideChat'
)[
0
];
scrollY
=
window
.
scrollY
+
document
.
body
.
scrollHeight
/
5
-
50
;
sideChat
.
style
.
top
=
scrollY
+
"px"
;
sideChat
.
style
.
top
=
scrollY
+
"px"
;
const
reposition
=
()
=>
{
// 화면 크기 바뀔때도 이래야함--> 추후수정
const
reposition
=
()
=>
{
// 화면 크기 바뀔때도 이래야함--> 추후수정
sideChat
.
style
.
transition
=
'800ms'
;
scrollY
=
window
.
scrollY
+
document
.
body
.
scrollHeight
/
5
-
50
;
sideChat
.
style
.
top
=
scrollY
+
"px"
;
sideChat
.
style
.
top
=
scrollY
+
"px"
;
}
document
.
addEventListener
(
'scroll'
,
reposition
);
...
...
Please
register
or
login
to post a comment