Open AmitDigga opened 1 month ago
DragControls
TransformControl
OrbitControl
Instead of exposing Group as ref, I am exposing another prop that allows to change behaviour at the prop
Group
export type DragControlsRef = { enabled: boolean } export const DragControlsModifed: ForwardRefComponent<DragControlsProps, DragControlsRef> = React.forwardRef< DragControlsRef, DragControlsProps >( ( { // ... rest }, fRef ) => { const refObject = React.useRef<DragControlsRef>({ enabled: true }) const refObjectAtStart = React.useRef<DragControlsRef>({ enabled: true }) const bind = useGesture( { onHover: ({ hovering }) => { // Some Changes here that were not handled by me }, onDragStart: ({ event }) => { refObjectAtStart.current.enabled = refObject.current.enabled // ... rest }, onDrag: ({ xy: [dragX, dragY], intentional }) => { if (refObjectAtStart.current.enabled === false) return // ... rest }, onDragEnd: () => { if (refObjectAtStart.current.enabled === false) return // ... rest }, }, // ... rest ) // ... rest } )
Describe the feature you'd like:
DragControls
ref behavior consistent with other controls likeTransformControl
,OrbitControl
, etc.DragControls
without changing the state.Suggested implementation:
Instead of exposing
Group
as ref, I am exposing another prop that allows to change behaviour at the prop