score:1

Accepted answer

first thing you are passing event as e to the function, so you have to do e.preventDefault() instead of event.preventDefault. Here your mousedown event is represented by e

Secondly, there is no need to listen to onMouseUp inside onMouseMove, following code should help you -

handleMouseDown(e) {
    e.preventDefault();
    let leftCol = e.target.parentElement
    let rightCol = e.target.parentElement.nextSibling
    let leftColOffset = leftCol.offsetWidth - e.pageX
    let rightColOffset = rightCol.offsetWidth + e.pageX
    onmousemove = (event) => {
        leftCol.style.width = leftColOffset + event.pageX + 'px';
        rightCol.style.width = rightColOffset - event.pageX + 'px';
    }
    onmouseup = () => {
        onmousemove = null;
    }
}

Related Query

More Query from same tag