# Bug with Slider::setRotaryParameters

**URL:** <https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504>\
**Category:** General JUCE discussion\
**Created:** [May 28, 2013, 12:55pm UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504 "2013-05-28T12:55:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shini](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/shini/32/186_2.png) [@shini](https://forum.juce.com/u/shini)\
**Post date:** [May 28, 2013, 12:55pm UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504/1 "2013-05-28T12:55:16Z")

</div>

I have a bug with the stopAtEnd parameter of setRotaryParameters:

If I do:

```auto
theKnob->setSliderStyle (Slider::Rotary);
theKnob->setRotaryParameters( float_Pi, float_Pi *3, false);
```

the knob do rotate indefinitely, but if I do:

```auto
theKnob->setSliderStyle (Slider::RotaryVerticalDrag);
theKnob->setRotaryParameters( float_Pi, float_Pi *3, false);
```

The value doesn’t wrap around, even if stopAtEnd is set to false. Tested on iOS and Android.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 29, 2013, 6:10pm UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504/2 "2013-05-29T18:10:38Z")

</div>

Not really a bug… If the slider’s in vertical drag mode, then it won’t wrap the value. The stopAtEnd parameter only really has a meaning when the mouse is being moved in a circle and can end up back at its starting point.

---

<div class="post-metadata">

**Author:** ![rwalters](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rwalters/32/284_2.png) [@rwalters](https://forum.juce.com/u/rwalters)\
**Post date:** [September 24, 2013, 5:26pm UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504/3 "2013-09-24T17:26:18Z")

</div>

I found this post after searching to discover if this behavior was a known bug or not.&nbsp; I agree with @shini, this seems like a bug to me, and should be fixed so that as you're dragging, the slider will wrap around if it reaches one end and the user continues the dragging gesture in the same direction.&nbsp; Alternatively, if the documentation for stopAtEnd would mention that it only has meaning for Rotary style, not other styles such as RotaryHorizontalVerticalDrag, that would also be acceptable.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [September 24, 2013, 5:48pm UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504/4 "2013-09-24T17:48:11Z")

</div>

I really don't see it as a bug!

The only reason that stopAtEnd exists is because when the motion is circular, you can end up back where you started - you can't do that when moving linearly, so it seems odd to me that you'd expect&nbsp;the value to keep snapping back.

(I will update the docs though!)

---

<div class="post-metadata">

**Author:** ![frankfilipanits](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/frankfilipanits/32/545_2.png) [@frankfilipanits](https://forum.juce.com/u/frankfilipanits)\
**Post date:** [September 24, 2013, 7:40pm UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504/5 "2013-09-24T19:40:09Z")

</div>

I, too, see this as a bug. &nbsp;There are certainly valid use cases where you would not want a rotary slider to hit a hard stop at any point along its rotation. &nbsp;One example: Azimuth. &nbsp;You wouldn't want to force the user to go back a full rotation to go from 359 degrees to 1 degree. &nbsp;And the preference for circular vs. linear drag to manipulate knobs on UIs is about 50/50 - enough that on more than one project I've made it a user preference.

stopAtEnd exists, so why \*not\* honor it for linearly manipulated controls?

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [April 2, 2019, 10:48am UTC](https://forum.juce.com/t/bug-with-slider-setrotaryparameters/10504/6 "2019-04-02T10:48:05Z")

</div>

I would like to emulate a hardware synth where you can turn a dial forever to manipulate a value. And I expected stopAtEnd to work for linear control.

At the end of ‘handleAbsoluteDrag’

```auto
		if (rotaryParams.stopAtEnd)
		{
			valueWhenLastDragged = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, newPos));
		}else
		{
			valueWhenLastDragged = owner.proportionOfLengthToValue (newPos - floor(newPos));
		}

```

And in ‘getMouseWheelDelta’

```auto
   	    auto newPos = currentPos + proportionDelta;
		if (rotaryParams.stopAtEnd)
			return owner.proportionOfLengthToValue(jlimit(0.0, 1.0, newPos)) - value;
		else
			return owner.proportionOfLengthToValue(newPos - floor(newPos)) - value;

```

And any other I haven’t thought of. 🙂
