Skip to content

Commit

Permalink
Improve draggable inputs
Browse files Browse the repository at this point in the history
why didn't i think of this
  • Loading branch information
yikuansun committed Dec 17, 2023
1 parent f2a454e commit 0e24e04
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion draggableInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ for (var numberInput of document.querySelectorAll("input[type=number]")) {
document.body.addEventListener("mousemove", inputDragReal);
document.body.style.cursor = "ew-resize";
});
numberInput.addEventListener("blur", function(e) {
disableDrag();
});
}

var disableDrag = function() {
Expand All @@ -31,6 +34,5 @@ window.addEventListener("blur", disableDrag);
window.addEventListener("mousemove", function(e) {
if (inputDragReal && (e.clientX < 10 || e.clientY < 10 || e.clientX > window.innerWidth - 10 || e.clientY > window.innerHeight - 10)) {
document.activeElement.blur();
disableDrag();
}
});

0 comments on commit 0e24e04

Please sign in to comment.