Hi,
I was getting ready to report this at the rails trak, but I thought
I''d post here first to make sure
I''m not missing anything.
There appears to be a bug when trying to create a slider which spans a
range including
negative values. When trying to set the slider to default to "0" in
the constructor, it will
instead go to the lowest available value.
For example:
new Control.Slider(''handle'', ''track'', {
range: $R(-10,10),
values: $R(-10,10),
sliderValue: 0, // won''t work if set to 0
onSlide: function(value) {console.log("value: " + value);}
});
Anyone else run into this problem?
Keith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Okay, I checked on Trac and there is already a bug report relating to this issue from a couple years back. I was able to find the expression in Slider.js where the bug is coming from, and wrote about it briefly on the bug report: http://dev.rubyonrails.org/ticket/5604#comment:2. Hope this helps, Take care, Keith On Mar 12, 3:27 pm, Keith <keith.hugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I was getting ready to report this at the rails trak, but I thought > I''d post here first to make sure > I''m not missing anything. > > There appears to be a bug when trying to create a slider which spans a > range including > negative values. When trying to set the slider to default to "0" in > the constructor, it will > instead go to the lowest available value. > > For example: > > new Control.Slider(''handle'', ''track'', { > range: $R(-10,10), > values: $R(-10,10), > sliderValue: 0, // won''t work if set to 0 > onSlide: function(value) {console.log("value: " + value);} > }); > > Anyone else run into this problem? > > Keith--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Keith Hughitt wrote:> Okay, > > I checked on Trac and there is already a bug report relating to this > issue from a couple years back. > I was able to find the expression in Slider.js where the bug is coming > from, and wrote about it briefly > on the bug report: http://dev.rubyonrails.org/ticket/5604#comment:2. > > Hope this helps, > > Take care, > Keith > >I don''t have time to try it, but perhaps this would work: // if sliderValue is an array, choose option i // otherwise set to sliderValue (which may be undefined, null, false, 0, ''0'', ''0.0'' etc.) var def = (Object.isArray(slider.options.sliderValue) ? slider.options.sliderValue[i] : slider.options.sliderValue); // use slider.range.start if def is undefined, null, or false // use 0 if the float value of def is exactly 0 slider.setValue(parseFloat(def) === 0 ? 0 : parseFloat(def || slider.range.start), i); - Ken --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---