document.querySelector('.angle input').addEventListener('input', function(e) {
const arrow = this.closest('.angle').querySelector('.angle-input-arrow');
arrow.style.transform = `rotate(${e.target.value}deg)`;
});
const angleInput = document.querySelector('.angle-input');
angleInput.addEventListener('mousedown', onAngleInput);
angleInput.addEventListener('mousemove', onAngleInput);
function onAngleInput(e) {
if (e.buttons === 1) {
const {
offsetX: x, offsetY: y,
target: t,
target: { offsetWidth: w, offsetHeight: h }
} = e;
const deg = (450 + (Math.atan2(y - h / 2, x - w / 2) * (180 / Math.PI) | 0)) % 360;
t.querySelector('.angle-input-arrow').style = `transform: rotate(${deg}deg)`;
t.closest('.angle').querySelector('input').value = deg;
}
}