fix: control modal head props
This commit is contained in:
parent
f8b0485479
commit
98a2589aa8
@ -3,7 +3,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import Draggable from 'react-draggable'
|
import Draggable from 'react-draggable'
|
||||||
|
|
||||||
export default function WithDraggable({ isShow, children }) {
|
export default function WithDraggable({ isShow, handle = '', children }) {
|
||||||
const [position, setPosition] = useState({ x: 0, y: 0 })
|
const [position, setPosition] = useState({ x: 0, y: 0 })
|
||||||
|
|
||||||
const handleOnDrag = (data) => {
|
const handleOnDrag = (data) => {
|
||||||
@ -13,7 +13,11 @@ export default function WithDraggable({ isShow, children }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isShow && (
|
{isShow && (
|
||||||
<Draggable position={{ x: position.x, y: position.y }} onDrag={(_, data) => handleOnDrag(data)} handle=".modal-header">
|
<Draggable
|
||||||
|
position={{ x: position.x, y: position.y }}
|
||||||
|
onDrag={(_, data) => handleOnDrag(data)}
|
||||||
|
handle={handle === '' ? '.modal-head' : handle}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Draggable>
|
</Draggable>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user