# Interaction between two sliders that update the same variable

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?

-
Yes. Each slider has its own update function that is applied only when that slider is moved. However the positions of both sliders always track the value of x. –  Michael E2 Sep 21 '13 at 15:30
There is a bug in your posted code. The constraint function should be If[Abs[# - Round[#]] < 0.3, x = Round[#], x = #] &. Note the additional # in the 2nd arg to If. –  m_goldberg Sep 22 '13 at 1:20
Thanks, m_goldberg, for showing the bug! –  Gabriel Sep 22 '13 at 7:51

You've only set the update function to snap in the first, so it will always show the current value of x and only when you dynamically change it using that slider, will the updating functionality be trickers causing it to snap. You can simply get what you are expecting by also including the snap functionality in the dynamically displayed value through:
DynamicModule[{x = 0},