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

Slider snaps to 100 when initially model-max is not defined #37

Closed mathurs closed 9 years ago

mathurs commented 9 years ago

I am noticing that the slider jumps to hundred when the value of model-max is not defined. This happens when I am using a field of a json object to bind to model-max. Something like options = {} and model-max binds to options.something. I am also setting pin-handle to min. Even if was set to 0 when null, it would be still graceful.

Thanks

gruberb commented 9 years ago

I've set model-max and also pin-handle="min", but it snaps every now and then to the maximum. As well as when I move the slider for the first time. Any solution or cause yet?

danielcrisp commented 9 years ago

By 100 do you mean 100%? i.e. fully to the right?

And are you populating the model-max with an XHR response or something? Hence the delay...

Any chance of a fiddle to demonstrate exactly what is happening?

gruberb commented 9 years ago

I actually cannot even make it work under the newest Angular-Version: http://jsfiddle.net/U3pVM/10838/

danielcrisp commented 9 years ago

That's because you are binding the min and modelMin values to the same variable... which essentially means they are locked together.

min is a setting, its the minimum allowed value. modelMin is the value the user chooses by sliding the handle. It cannot be less than min

Take a look at this updated fiddle:

http://jsfiddle.net/bupvp7fw/2/

mathurs commented 9 years ago

Sorry, yes I meant to the right most value. It so happens its value was 100.

So its like model-max=A.percentSample, where A is a JS object initialized to {}. Although there is no delay because of XHR, the modeled key just does not exist in the object to begin with. So its undefined to begin with and as soon as I interact with the slider it moves to the maximum value.

Will try to provide a jsfiddle asap.

Thanks for your good work and your reply, saurabh

On Thu, Nov 27, 2014 at 8:56 PM, danielcrisp notifications@github.com wrote:

By 100 do you mean 100%? i.e. fully to the right?

And are you populating the model-max with an XHR response or something? Hence the delay...

Any chance of a fiddle to demonstrate exactly what is happening?

— Reply to this email directly or view it on GitHub https://github.com/danielcrisp/angular-rangeslider/issues/37#issuecomment-64803159 .

gruberb commented 9 years ago

Thanks @danielcrisp for the Fiddle. I wasn't able to reproduce... I'll try the following days. I am using foundation and other frameworks in my app, so maybe there is a conflict somewhere.

danielcrisp commented 9 years ago

Closing unless there are still problems that someone can provide a fiddle for