|
|
@ -13,9 +13,7 @@ function clamp(value, min, max) {
|
|
|
|
return value
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function WidthHandler(props) {
|
|
|
|
export default function WidthHandler({ onChange, onConfirm, innerRef, paddingHorizontal }) {
|
|
|
|
const { onChange, innerRef, paddingHorizontal } = props
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const startX = React.useRef(null)
|
|
|
|
const startX = React.useRef(null)
|
|
|
|
const startWidth = React.useRef(null)
|
|
|
|
const startWidth = React.useRef(null)
|
|
|
|
|
|
|
|
|
|
|
@ -34,6 +32,15 @@ export default function WidthHandler(props) {
|
|
|
|
return () => window.removeEventListener('mousemove', handleMouseMove)
|
|
|
|
return () => window.removeEventListener('mousemove', handleMouseMove)
|
|
|
|
}, [innerRef, onChange])
|
|
|
|
}, [innerRef, onChange])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
|
|
|
function handleMouseUp() {
|
|
|
|
|
|
|
|
startX.current = null
|
|
|
|
|
|
|
|
onConfirm()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('mouseup', handleMouseUp)
|
|
|
|
|
|
|
|
return () => window.removeEventListener('mouseup', handleMouseUp)
|
|
|
|
|
|
|
|
}, [onConfirm])
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
// eslint-disable-next-line
|
|
|
|
// eslint-disable-next-line
|
|
|
|
<div
|
|
|
|
<div
|
|
|
@ -42,9 +49,6 @@ export default function WidthHandler(props) {
|
|
|
|
startX.current = e.pageX
|
|
|
|
startX.current = e.pageX
|
|
|
|
startWidth.current = innerRef.current.clientWidth
|
|
|
|
startWidth.current = innerRef.current.clientWidth
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onMouseUp={() => {
|
|
|
|
|
|
|
|
startX.current = null
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
role="separator"
|
|
|
|
role="separator"
|
|
|
|
aria-orientation="vertical"
|
|
|
|
aria-orientation="vertical"
|
|
|
|
aria-valuemin={minWidth}
|
|
|
|
aria-valuemin={minWidth}
|
|
|
|