Fix right dragbar

pull/4798/head
ioedeveloper 6 months ago
parent 79a436262d
commit fea9c81dfc
  1. 32
      libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx
  2. 4
      libs/remix-ui/app/src/lib/remix-app/remix-app.tsx

@ -54,7 +54,8 @@ const DragBar = (props: IRemixDragBarUi) => {
const handleResize = () => { const handleResize = () => {
if (!props.refObject.current) return if (!props.refObject.current) return
setOffSet(props.refObject.current.offsetLeft) setOffSet(props.refObject.current.offsetLeft)
setDragBarPosX(props.refObject.current.offsetLeft + props.refObject.current.offsetWidth) if (props.layoutPosition === 'left') setDragBarPosX(props.refObject.current.offsetLeft + props.refObject.current.offsetWidth)
else if (props.layoutPosition === 'right') setDragBarPosX(props.refObject.current.offsetLeft)
} }
useEffect(() => { useEffect(() => {
@ -66,15 +67,28 @@ const DragBar = (props: IRemixDragBarUi) => {
function stopDrag(data: any) { function stopDrag(data: any) {
setDragState(false) setDragState(false)
if (data.x < props.minWidth + offset) { if (props.layoutPosition === 'left') {
setDragBarPosX(offset) if (data.x < props.minWidth + offset) {
props.setHideStatus(true) setDragBarPosX(offset)
} else { props.setHideStatus(true)
props.refObject.current.style.width = data.x - offset + 'px' } else {
setTimeout(() => { props.refObject.current.style.width = data.x - offset + 'px'
setTimeout(() => {
props.setHideStatus(false)
setDragBarPosX(offset + props.refObject.current.offsetWidth)
}, 300)
}
} else if (props.layoutPosition === 'right') {
if (window.innerWidth - data.x < props.minWidth) {
setDragBarPosX(props.refObject.current.offsetLeft)
props.setHideStatus(false) props.setHideStatus(false)
setDragBarPosX(offset + props.refObject.current.offsetWidth) } else {
}, 300) props.refObject.current.style.width = (window.innerWidth - data.x) + 'px'
setTimeout(() => {
props.setHideStatus(false)
setDragBarPosX(props.refObject.current.offsetLeft)
}, 300)
}
} }
} }

@ -98,7 +98,7 @@ const RemixApp = (props: IRemixAppUi) => {
props.app.layout.event.on('minimizepinnedpanel', () => { props.app.layout.event.on('minimizepinnedpanel', () => {
setTimeout(() => { setTimeout(() => {
setHideSidePanel(true) setHidePinnedPanel(true)
}, 1000) }, 1000)
}) })
@ -220,7 +220,7 @@ const RemixApp = (props: IRemixAppUi) => {
minWidth={285} minWidth={285}
refObject={pinnedPanelRef} refObject={pinnedPanelRef}
hidden={hidePinnedPanel} hidden={hidePinnedPanel}
setHideStatus={setHideSidePanel} setHideStatus={setHidePinnedPanel}
layoutPosition='right' layoutPosition='right'
></DragBar> ></DragBar>
</div> </div>

Loading…
Cancel
Save