Venturocket / angular-slider

Slider directive for AngularJS.
MIT License
262 stars 121 forks source link

knob "jumpiness" #11

Closed sander76 closed 10 years ago

sander76 commented 10 years ago

Thanks for this slider !

One thing I am experiencing though is what I would call the "jumpiness" of the slider knob: If I use your example.html and click on a knob it "jumps" to the value I have clicked (mostly one value next to the current value). But I am not clicking to go to a value. I am clicking on the knob to grab it.

I know it is a minor detail, but I think solving this makes this control look and work even better.

Sander.

jonathancochran commented 10 years ago

Seconded. Any ideas what's causing this or how to fix?

rjoo commented 10 years ago

I agree a solution would be nice. I haven't tinkered enough with the slider but I think the issue stems from the calculation in finding the mouse when clicking on the knob. The below hack makes it a bit better in that if you click the center of the knob it doesn't jump. It still jumps slightly when you click the left or right side of the knob.

// get the raw value where the mouse/finger/etc is starting
var newValue = minValueDecoded +
               (valueRangeDecoded * percentFromOffset(bringOffsetInRange(currentX + minOffset - offsetLeft(element))) /
                100.0) - 2; // <-- Just subtracted the value by 2
drgould commented 10 years ago

@rjoo That calculation isn't the root of the problem. It's just not setting the knob position to stay under the mouse on mousedown like it does on mousemove.

I know what needs to be done to fix it, I just haven't had the time to work on it yet. I'll be able to get to it this weekend.

sander76 commented 10 years ago

Great ! thanks in advance !

drgould commented 10 years ago

The fix for this is up. If it still feels jumpy, set the stickiness to 1.