danielcrisp / angular-rangeslider

Simple directive that creates a range slider for Angular, styled to match Bootstrap-styled form elements
danielcrisp.github.io/angular-rangeslider/
MIT License
223 stars 122 forks source link

onMouseUp fires multiple times #39

Closed primoz990 closed 9 years ago

primoz990 commented 9 years ago

I just implemented the range slider. Working well, but i noticed that the onMouseUp event gets called 1 time, the second time i release the handle it gets called 2 times, 3rd 3 times...and so on... The problem(i gues) is that $document.bind(offEvent, ...); is called every time when an handle is pressed. This leads to this that the offEvent is bound X times to a slider and the onMouseUp event gets called X times.

I want to bind an http get task on the onMouseUp, so i realy need the event to fire just once.

My quick fix was to unbind the offEvent every time before bind, but that is not the best solution i gues: $document.unbind(offEvent); $document.bind(offEvent, ...) ...

danielcrisp commented 9 years ago

Good spot, it should have been unbinding the listener on mouseup - I've pushed a fix in v0.0.11

danielcrisp commented 9 years ago

https://github.com/danielcrisp/angular-rangeslider/blob/master/angular.rangeSlider.js#L571

primoz990 commented 9 years ago

Woow, that was a fast response :D v0.0.11 Works like a charm, thanks a lot :)

danielcrisp commented 9 years ago

You're lucky - I happen to be using the rangeslider in a project today so I needed the fix too :-)