Drag handle works once then completely stops responding, help
const handle = document.querySelector('.drag-handle');
const box = document.querySelector('.box');
function onDrag(e) {
box.style.left = e.clientX + 'px';
box.style.top = e.clientY + 'px';
}
handle.addEventListener('mousedown', () => {
document.addEventListener('mousemove', onDrag);
document.addEventListener('mouseup', () => {
document.removeEventListener('mousemove', onDrag);
});
});
Reply with what is broken and how you would fix it.