Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to implement a slider whose control range varies depending on the current value:

Dynamic @Which[asd < 10, {1, 10}, asd >= 10 , {9, 50, 1}]]}

However I now have the problem that the slider remains in place once the control scales change and thus the value "leaps" as soon as the scales change. To Illustrate: once i reach ten the scale changes but the slider remains in place and thus the value goes immediately to 50 (the "new" ten). Is it possible to have the slider jump instead of the value? Perhaps by briefly locking the value at ten?

share|improve this question
up vote 1 down vote accepted

I believe the jump in value of asd happens because you're dragging the indicator with the mouse when the range is reset. Here is a way that does what you want, I think. It interrupts the mouse-dragging by creating a new Slider when the boundary is reached.

   Which[asd < 10, {1, 10}, asd >= 10, {9, 50, 1}]]}

(Personally, I don't like the way it behaves, but I think it's what you're after. If you want the mouse action to continue, then the mouse position on the screen would need to be changed. As yet, I'm not sure this can be done.)

share|improve this answer

Maybe this is also an acceptable approach depending on your needs.

{Slider[Dynamic[asd, (asd = If[# <= 10, #, Round@#]) &], {1, 50}], Dynamic@asd}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.