Display number as simple text but allow click + drag to change the value. If the number is simply clicked then it displays an input so that a precise value can be entered.
With Bower: $ bower install --save draggable-number.js
Or manually download the latest release.
Include the draggable-number.min.js file and then call new DraggableNumber(element)
.
<input class="numeric-input" value="42" />
<script src="dist/draggable-number.min.js"></script>
<script>
new DraggableNumber(document.getElementsByClassName('numeric-input')[0]);
</script>
You can set the draggableNumber options when creating a new instance,
new DraggableNumber(element, {
min: 0,
max: 100,
dragThreshold: 5
});
Return the current value as float.
var value = item.get();
Set the value of the element. This update the input and span value.
item.set(42);
Set the minimum value.
item.setMin(5);
Set the maximum value.
item.setMax(5);
Remove the DraggableNumber element, leaving the original input field.
item.destroy();