Is it possible to have a slider with discrete / integer steps?
I have tried UserStep but it didn’t seem to work.
I have also tried setting the slider value to a rounded version of its own value in the ValueChanged event. This kind of works but if I move the slider quickly left and right something strange happens and the slider starts to issue continuous events without stopping, even after I stop moving the slider.
Not quite sure why this is, but in any case it seems like a bit of a hack.
The effect I want to achieve (as in the clock demo) is a snapping of the slider to the steps in the range, ie. the clock snaps to every 5 minute step.
I think I need an Attractor (as is used in the clock) but I can’t figure out how to use it. The clock version is part of <ClockHand> so it’s tricky to see how it fits in with a linear slider.
But this doesn’t move in steps, it just moves in fractional values. Hence I have tried to rebuild a custom slider control that will move in steps (with an Attractor).
after a little joint effort, we’ve come up with a pretty neat solution for a “stepped slider”. There’s a bit of hard-coded math, but I’m sure you’ll figure out how to make it more abstract
<App>
<Panel Padding="24">
<JavaScript>
var Observable = require("FuseJS/Observable");
var progress = Observable(0.5);
var quantized = progress.map(function(x) {
var res = x * 100;
res = Math.round(res / 10) * 10;
return res / 100;
});
module.exports = {
progress: progress,
quantized: quantized
};
</JavaScript>
<AttractorConfig Unit="Points" Type="SmoothSnap" Duration="0.24" ux:Global="snapConfig" />
<RangeControl ux:Name="rangeControl" Value="{progress}" Minimum="0" Maximum="1">
<LinearRangeBehavior ux:Name="slide"/>
<Rectangle ux:Name="bgRect" Layer="Background" Color="#808080" Height="2">
<Circle ux:Name="indicator" Anchor="50%,50%" Alignment="Left" Color="#ff0000"
Width="20" Height="20" X="attract({quantized} * width(bgRect), snapConfig)" />
</Rectangle>
</RangeControl>
</Panel>
</App>