So I’m attempting to make a speed slider for a small toy project. Instead of having a range slider with a max/min and regular increments I’d like to be able to define custom options.
I’ve tried to create a slider with 3 options 1000, 500 & 250. However, as the slider moves, the speed value it being set to values between 1-100. Any idea what’s going wrong here?
The Elm code looks fine, this seems like a HTML issue. I haven’t come across datalist before so nothing is jumping out at me. I’d suggest trying to get it working in a plain HTML file first, then translate it back to Elm.
Also, you should set min and max attributes right after the type attribute and set defaultValue last. This will avoid the initial position of the slider being at the wrong location.
I couldn’t stop playing with this a little more. This is perhaps an ugly behaving implementation of a slider with discrete options: https://ellie-app.com/MV87KBNWGMa1
You don’t even need the datalist with this method and even works well in Firefox which has not implemented the list attribute of sliders.