|
|
@ -26,15 +26,22 @@ const DragBar = (props: IRemixDragBarUi) => { |
|
|
|
initialWidth.current = props.refObject.current.clientWidth |
|
|
|
initialWidth.current = props.refObject.current.clientWidth |
|
|
|
if (props.maximiseTrigger > 0) { |
|
|
|
if (props.maximiseTrigger > 0) { |
|
|
|
const width = 0.4 * window.innerWidth |
|
|
|
const width = 0.4 * window.innerWidth |
|
|
|
|
|
|
|
console.log(width, props.refObject.current.offsetWidth) |
|
|
|
|
|
|
|
if (width > props.refObject.current.offsetWidth) { |
|
|
|
props.refObject.current.style.width = width + 'px' |
|
|
|
props.refObject.current.style.width = width + 'px' |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
setDragBarPosX(offset + width) |
|
|
|
setDragBarPosX(offset + width) |
|
|
|
|
|
|
|
}, 300) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, [props.maximiseTrigger]) |
|
|
|
}, [props.maximiseTrigger]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (props.maximiseTrigger > 0) { |
|
|
|
if (props.maximiseTrigger > 0) { |
|
|
|
props.refObject.current.style.width = initialWidth.current + 'px' |
|
|
|
props.refObject.current.style.width = initialWidth.current + 'px' |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
setDragBarPosX(offset + initialWidth.current) |
|
|
|
setDragBarPosX(offset + initialWidth.current) |
|
|
|
|
|
|
|
}, 300) |
|
|
|
} |
|
|
|
} |
|
|
|
}, [props.resetTrigger]) |
|
|
|
}, [props.resetTrigger]) |
|
|
|
|
|
|
|
|
|
|
@ -51,19 +58,22 @@ const DragBar = (props: IRemixDragBarUi) => { |
|
|
|
return () => window.removeEventListener('resize', handleResize) |
|
|
|
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) { |
|
|
|
setDragBarPosX(offset) |
|
|
|
setDragBarPosX(offset) |
|
|
|
props.setHideStatus(true) |
|
|
|
props.setHideStatus(true) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
props.refObject.current.style.width = (data.x - offset) + 'px' |
|
|
|
props.refObject.current.style.width = (data.x - offset) + 'px' |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
props.setHideStatus(false) |
|
|
|
props.setHideStatus(false) |
|
|
|
setDragBarPosX(offset + props.refObject.current.offsetWidth) |
|
|
|
setDragBarPosX(offset + props.refObject.current.offsetWidth) |
|
|
|
|
|
|
|
}, 300) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function startDrag () { |
|
|
|
function startDrag() { |
|
|
|
setDragState(true) |
|
|
|
setDragState(true) |
|
|
|
} |
|
|
|
} |
|
|
|
return <> |
|
|
|
return <> |
|
|
|