This is a minimum use case example of the javascript library slid3r
. It appends a slider into any SVG context you desire. See the library's main repo for more information.
Last active
August 29, 2017 20:45
-
-
Save nstrayer/558a63263bd60b3a722c92a2fe338345 to your computer and use it in GitHub Desktop.
slid3r demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Slid3r Demo</title> | |
</head> | |
<body> | |
<p>Current slider value is <span id = "sliderValue">3</span></p> | |
<p>Slider last dropped on <span id = "sliderEndValue">3</span></p> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://rawgit.com/nstrayer/slid3r/master/dist/slid3r.js"></script> | |
<script type = 'module'> | |
const svg = d3.select('body').append('svg') | |
.attr('height', 500) | |
.attr('width', 500) | |
const mySlider = slid3r() | |
.width(200) | |
.range([0,10]) | |
.startPos(3) | |
.label('Super Cool Slider') | |
.loc([50, 50]) | |
.onDrag((pos) => d3.select('#sliderValue').text(pos)) | |
.onDone((pos) => d3.selectAll('#sliderValue,#sliderEndValue').text(pos)); | |
svg.append('g').call(mySlider); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment