fixes dragbar handle

pull/5370/head
bunsenstraat 2 years ago
parent 17d4887f34
commit 96d0343656
  1. 14
      libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx
  2. 2
      libs/remix-ui/app/src/lib/remix-app/style/remix-app.css

@ -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 <>

@ -32,7 +32,7 @@ pre {
display : flex; display : flex;
flex-direction : row-reverse; flex-direction : row-reverse;
width : 320px; width : 320px;
transition : width 1s; transition : width 0.25s;
} }
.highlightcode { .highlightcode {

Loading…
Cancel
Save