EasyUI Forum
November 03, 2025, 03:05:29 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Slider : extending to non linear scale  (Read 9774 times)
delta2
Newbie
*
Posts: 2


View Profile
« on: March 06, 2014, 09:53:32 AM »

I need to configure the slider to use a non linear scale with easing at the start.

I digged into the slider part of the minified code and added 2 lines after 12341...

Code:
12341 opts.value=_933;
-----  var slider_ease_in_factor = 0.5
-----  opts.value = Math.round(Math.pow(opts.value/opts.max,slider_ease_in_factor)*opts.value);

... which does what I want to the ToolTip but I can't work out how to get it saved to the input value so that it gets returned with the form.

Anyway I'm sure it should be possible by extending the slider object and not digging into the sourcecode.

Anyone got any suggestions. Thanks. Stu.

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 06, 2014, 08:31:14 PM »

Please try to download the updated slider plugin from http://www.jeasyui.com/easyui/plugins/jquery.slider.js and include it to the page. The new slider plugin has 'converter' option that allows you determine how to convert a value to the slider position or the slider position to the value.
Code:
<input id="ss" class="easyui-slider" style="width:300px" 
data-options="
showTip:true,
max:40000,
converter:{
toPosition:function(value, size){
var opts = $(this).slider('options');
return (value-opts.min)/(opts.max-opts.min)*size;
},
toValue:function(pos, size){
var opts = $(this).slider('options');
return opts.min + (opts.max-opts.min)*(pos/size);
}
}
">
Logged
delta2
Newbie
*
Posts: 2


View Profile
« Reply #2 on: March 07, 2014, 01:22:20 AM »

Thanks. Very elegant solution. It's working perfectly for me. So to get my slider "easing in" i adjusted the position by a factor of ^ 2 and the value by a factor of ^ 0.5 as follows:

                <input name="flowrate" class="easyui-slider" value="12" style="width:200px"
                      data-options="
                           showTip:true,
                            min:0,
                            max:1600,
                            rule:[0,'|',100,'|',400,'|',900,'|',1600],
                            converter:{
                                toPosition:function(value, size){
                                    var opts = $(this).slider('options');
                                    //return (value-opts.min)/(opts.max-opts.min)*size;
                                    return  Math.pow((value-opts.min)/(opts.max-opts.min),0.5)*size;
                                },
                                toValue:function(pos, size){
                                    var opts = $(this).slider('options');
                                    //return opts.min + (opts.max-opts.min)*(pos/size);
                                    return opts.min + (opts.max-opts.min)*Math.pow((pos/size),2);
                                }
                            }"
            >
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!