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