|
|
@ -15,18 +15,23 @@ const DragBar = (props: IRemixDragBarUi) => { |
|
|
|
const [offset, setOffSet] = useState<number>(0) |
|
|
|
const [offset, setOffSet] = useState<number>(0) |
|
|
|
const nodeRef = React.useRef(null) // fix for strictmode
|
|
|
|
const nodeRef = React.useRef(null) // fix for strictmode
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
// arbitrary time out to wait the the UI to be completely done
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
setOffSet(props.refObject.current.offsetLeft) |
|
|
|
|
|
|
|
setDragBarPosX(offset + props.refObject.current.offsetWidth) |
|
|
|
|
|
|
|
}, 1000) |
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
setDragBarPosX(offset + (props.hidden ? 0 : props.refObject.current.offsetWidth)) |
|
|
|
setDragBarPosX(offset + (props.hidden ? 0 : props.refObject.current.offsetWidth)) |
|
|
|
}, [props.hidden, offset]) |
|
|
|
}, [props.hidden, offset]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleResize = () => { |
|
|
|
|
|
|
|
setOffSet(props.refObject.current.offsetLeft) |
|
|
|
|
|
|
|
setDragBarPosX(props.refObject.current.offsetLeft + props.refObject.current.offsetWidth) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
window.addEventListener('resize', handleResize) |
|
|
|
|
|
|
|
// TODO: not a good way to wait on the ref doms element to be rendered of course
|
|
|
|
|
|
|
|
setTimeout(() => |
|
|
|
|
|
|
|
handleResize(), 2000) |
|
|
|
|
|
|
|
return () => window.removeEventListener('resize', handleResize) |
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
function stopDrag (e: MouseEvent, data: any) { |
|
|
|
function stopDrag (e: MouseEvent, data: any) { |
|
|
|
setDragState(false) |
|
|
|
setDragState(false) |
|
|
|
if (data.x < props.minWidth) { |
|
|
|
if (data.x < props.minWidth) { |
|
|
|