=radiaSlider=
a pure JavaScript circular/linear knob-style slider
Features
* works on desktop, mobile and tablets
* small size (minified ~6 Kb)
* no dependencies
* pure JavaScript (ES5)
* browser and Node.js friendly
Demo
Circular / linear
Quickstart
- create a canvas and the value field
<canvas id="myCanvas" width="300" height="300"></canvas>
<span id="value1"></span>
Circular slider
<script src="slider-circular.min.js"></script>
<script>
var slider = new Slider({ canvasId: "myCanvas", continuousMode: true, x0: 150, y0: 150 });
slider.addSlider({
id: 1,
radius: 50,
min: 0,
max: 30,
step: 5,
color: "#104b63",
changed: function (v) {
document.getElementById('value1').innerHTML = "Angle: " + v.deg + " deg, value: " + v.value;
}
});
</script>
Linear slider
<script src="slider-linear.min.js"></script>
<script>
var slider = new Slider({ canvasId: "myCanvas", continuousMode: true, vertical: false });
slider.addSlider({
id: 1
width: 50,
min: 0,
max: 30,
step: 5,
color: "#104b63",
changed: function (v) {
document.getElementById('value1').innerHTML = "Width: " + v.width + " px, value: " + v.value;
},
x0: 30,
y0: 30
});
</script>
Get/set value programmatically
If you want to change the value programmatically, use:
slider.setSliderValue(<sliderId>, <value>);
To get the current value:
slider.sliders[<sliderId>].normalizedValue
slider.sliders[<sliderId>].ang_degrees
slider.sliders[<sliderId>].endAngle
slider.sliders[<sliderId>].value
Using Node.js
Radia slider can be used either in the Browser or in the Node.js environment. For a React.js example look here.
License
This project is licenced under the MIT License.