Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
love_飞影
Neos
Commits
ad9e005d
Commit
ad9e005d
authored
Mar 26, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make modal dragglable
parent
7eb8968b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
src/ui/Duel/checkCardModal.tsx
src/ui/Duel/checkCardModal.tsx
+50
-1
No files found.
src/ui/Duel/checkCardModal.tsx
View file @
ad9e005d
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
use
Ref
,
use
State
}
from
"
react
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
store
}
from
"
../../store
"
;
import
{
...
...
@@ -19,6 +19,8 @@ import {
sendSelectCardResponse
,
sendSelectChainResponse
,
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
type
{
DraggableData
,
DraggableEvent
}
from
"
react-draggable
"
;
import
Draggable
from
"
react-draggable
"
;
import
NeosConfig
from
"
../../../neos.config.json
"
;
const
CheckCardModal
=
()
=>
{
...
...
@@ -32,6 +34,38 @@ const CheckCardModal = () => {
const
[
response
,
setResponse
]
=
useState
<
number
[]
>
([]);
const
defaultValue
:
number
[]
=
[];
// Draggable 相关
const
[
draggable
,
setDraggable
]
=
useState
(
false
);
const
[
bounds
,
setBounds
]
=
useState
({
left
:
0
,
top
:
0
,
bottom
:
0
,
right
:
0
,
});
const
draggleRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
onStart
=
(
_event
:
DraggableEvent
,
uiData
:
DraggableData
)
=>
{
const
{
clientWidth
,
clientHeight
}
=
window
.
document
.
documentElement
;
const
targetRect
=
draggleRef
.
current
?.
getBoundingClientRect
();
if
(
!
targetRect
)
{
return
;
}
setBounds
({
left
:
-
targetRect
.
left
+
uiData
.
x
,
right
:
clientWidth
-
(
targetRect
.
right
-
uiData
.
x
),
top
:
-
targetRect
.
top
+
uiData
.
y
,
bottom
:
clientHeight
-
(
targetRect
.
bottom
-
uiData
.
y
),
});
};
const
onMouseOver
=
()
=>
{
if
(
draggable
)
{
setDraggable
(
false
);
}
};
const
onMouseOut
=
()
=>
{
setDraggable
(
true
);
};
// TODO: 这里可以考虑更好地封装
const
sendResponseHandler
=
(
handlerName
:
string
|
undefined
,
...
...
@@ -65,6 +99,10 @@ const CheckCardModal = () => {
dispatch
(
setCheckCardModalIsOpen
(
false
));
dispatch
(
resetCheckCardModal
());
}
}
onMouseOver=
{
onMouseOver
}
onMouseOut=
{
onMouseOut
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
submit
</
Button
>
...
...
@@ -77,6 +115,10 @@ const CheckCardModal = () => {
dispatch
(
setCheckCardModalIsOpen
(
false
));
dispatch
(
resetCheckCardModal
());
}
}
onMouseOver=
{
onMouseOver
}
onMouseOut=
{
onMouseOut
}
onFocus=
{
()
=>
{}
}
onBlur=
{
()
=>
{}
}
>
cancel
</
Button
>
...
...
@@ -85,6 +127,11 @@ const CheckCardModal = () => {
)
}
</>
}
modalRender=
{
(
modal
)
=>
(
<
Draggable
disabled=
{
!
draggable
}
bounds=
{
bounds
}
onStart=
{
onStart
}
>
<
div
ref=
{
draggleRef
}
>
{
modal
}
</
div
>
</
Draggable
>
)
}
width=
{
800
}
>
<
CheckCard
.
Group
...
...
@@ -122,6 +169,8 @@ const CheckCardModal = () => {
style=
{
{
width
:
100
}
}
/>
}
onMouseEnter=
{
onMouseOver
}
onMouseLeave=
{
onMouseOut
}
value=
{
option
.
response
}
/>
</
Popover
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment