I'm basing this on the code found in the Introduction to Dynamics. I added one more slider which doesn't use the "round and snap" feature given in the link above:
DynamicModule[{x = 0},
Column@{Slider[
Dynamic[x,
If[Abs[# - Round[#]] < 0.3, x = Round[x], x = #] &], {0, 5}]
, Slider[Dynamic[x], {0, 5}]
, Dynamic[x]
}]
When sliding the second slider, I would have though the first one one stay snapped until x > 0.3
, but that is not the case: the first slider moves together with the second one.
Is the update function only evaluating when the first slider is moved?
x
. $\endgroup$If[Abs[# - Round[#]] < 0.3, x = Round[#], x = #] &
. Note the additional#
in the 2nd arg toIf
. $\endgroup$