Range2DSlider Range and Slider 2d in one jQuery plugin. Support touch devices
(追記) (追記ここまで)
A
lot of configuration options make it one of the best plugins for make slider and range. Just
look at what it can do:
Simple 2d slider.
jQuery('#slider').range2DSlider({
grid:false,
axis:[[0,2,5,7,10],[0,5,10]],
projections:true,
showLegend:[1,1],
allowAxisMove:['both'],
printLabel:function( val ){
this.projections&&this.projections[0].find('.xdsoft_projection_value_x').text(val[1].toFixed(5));
return val[0].toFixed(5);
}
})
.range2DSlider('value',[[1,4],[3,1],[6,6]]);
or usual range slider, alternative native input type="range", but with support for multiple values
jQuery('#slider').range2DSlider({
template:'horizontal',
value:[[5,0],[7,0]],
onlyGridPoint:true,
round:true,
axis:[[-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10]]
});
Vertical variant, the same slider input type="range"
jQuery('#slider').range2DSlider({
template:'vertical',
value:[[0,5]],
showRanges:[[0,1]],
style:'float:left;margin-left:25px;',
axis:[[0,1],[0,10]],
round:true,
printLabel:function( val ){
return val[1]+' yo';
}
});
In tooltip over(under/to the left/to the right) slider can display not only the current values. All pretty simple customise
<input class="slider31">
<script>
var values = [];
var ranges = [];
var cities = [
'Abuja',
'Accra',
'Adamstown',
'Addis',
'Algiers',
'Alofi',
'Amman',
'Amsterdam',
'Andorra',
'Ankara',
'Antananarivo',
'Apia',
'Ashgabat',
'Asmara',
'Astana',
'Asuncion',
'Athens',
'Avarua',
'Baghdad',
'Baku',
'Bamako',
'Bandar',
'Bangkok',
'Bangui',
'Banjul',
'Basseterre',
'Beijing',
'Beirut',
'Belgrade',
'Belmopan'
];
for(var i = -10,k=0;i<=10;i++,k++ ){
values.push([i,Math.sin(i),cities[i+10]]);
if( i<10 )
ranges.push([k,k+1]);
}
jQuery('.slider31').range2DSlider({
x:'right',
y:'top',
style:'margin-top:50px;',
showLegend:[0,0],
showRanges:ranges,
axis:[[-10,10],[-1.5,1.5]],
allowAxisMove:['y'],
printLabel:function( val ){
return val[1].toFixed(2)+'<br>'+val[2];
}
}).range2DSlider('value',values);
</script>
Do not like the look?
<input id="slider41" />
<style type="text/css">.
xdsoft_custom .xdsoft_range2dslider_runner{
border-radius:1px;
margin:0px 0px -4px -8px !important;
background:rgba(0,0,127,0.5);
border:1px outset #ddd;
}
.xdsoft_custom .xdsoft_range2dslider_box{
min-height:8px;
background:rgba(127,127,127,0.5);
border-radius:1px;
border-style:solid;
}
.xdsoft_custom .xdsoft_slider_label{
background: red;
color: #fff;
bottom: 22px !important;
}
.xdsoft_custom .xdsoft_slider_label.xdsoft_slider_label_top:after{
border-top-color:red;
}
</style>
<script>
jQuery('#slider41').range2DSlider({
grid:false,
height:0,
className:'xdsoft_custom',
style:'margin-top:50px;',
showLegend:[1,0],
axis:[[0,0.1]],
tooltip:['top'],
alwShowTooltip:[true],
allowAxisMove:['x'],
printLabel:function( val ){
return val[0].toFixed(3);
}
}).range2DSlider('value',[[0.05,0]]);
</script>
All that you see above is not strictly into a slider, and is a combination of a specific setting. You can create a configuration for all cases. Under the cut description of the settings and configurations, and interested can immediately download the plugin and to try it yourself
Settings
jQuery('.slider1').range2DSlider({
axis:[
[-10,-5,0,5,10],
[-10,10]
]
});
Result
jQuery('.slider2').range2DSlider({
value:[
[0,0],
[5,5],
[1,6],
[9,9],
[10,10]
]
});
Result
Default: false
jQuery('.slider3').range2DSlider({
projections:true
});
Result
Default: false
jQuery('.slider4').range2DSlider({
value:[[1,0],[5,0]],//will be two sliders
showRanges:[[0,1]], //combine these two sliders
template:'horizontal' //this is not setting a configuration setting
//to simplify the work with the plugin
});
Result
Default: "skin1"
jQuery('.slider5').range2DSlider({
skin:'myskin'
});
Default: ""
jQuery('.slider5').range2DSlider({
className:'myclass myclass2'
});
Default: ""
jQuery('.slider6').range2DSlider({
value:[[0,5]],
showRanges:[[0,1]],
style:'float:left;margin-left:25px;',
axis:[[0,1],[0,10]],
template:'vertical'
});
Result
Default: "100px"
jQuery('.slider7').range2DSlider({
height:'10px'
});
Default: "auto"
jQuery('.slider8').range2DSlider({
width:'30%'
});
Default: "left"
Default: "bottom"
jQuery('.slider9').range2DSlider({
x:'right',
y:'top'
});
Result
Default: true
Default: true
Default: false
Default:
{
width:0.5,
color:'#888',
dashed:[5,2]
}
jQuery('.slider10').range2DSlider({
grid:true,
gridStep:[40,40],
gridStyle:{
width:1.5,
color:'red',
dashed:[1,2]
}
});
Result
Default: false
Default: Math.round
jQuery('.slider11').range2DSlider({
round:true,
roundMethod:function(val){return val>4?5:3;}
});
Default: [true,true]
jQuery('.slider').range2DSlider({
showLegend:false,
});
Default: false
jQuery('.slider').range2DSlider({
showLegend:[true,false]
});
jQuery('.slider').range2DSlider({
showLegend:[false,false],
recalcLegends:true
});
Default: ['top']
Default: [true]
jQuery('.slider').range2DSlider({
tooltip:['top','right','bottom','left'],
value:[[2,5],[4,5],[6,5],[8,5]],
alwShowTooltip:[true,true,true,false]
});
Result
Default: false
jQuery('.slider').range2DSlider({
template:'horizontal',
round:true,
onlyGridPoint:true
});
Result
Default: false
Default: 'both'
jQuery('.slider').range2DSlider({
value:[[1,1],[3,3],[5,5]],
allowAxisMove:['x','y','both']
});
Result
Default:
function( value ){
return value[0].toFixed(2)+'-'+value[1].toFixed(2)
}
In this he served in the DOM element of the slider. Using it, you can turn to its child
elements: tooltip or projections
jQuery('.slider').range2DSlider({
value:[5,5],
projections:true,
printLabel:function( val ){
this.projections
&&this.projections[0]
.find('.xdsoft_projection_value_x')
.text(val[1].toFixed(5));
return val[0].toFixed(5);
}
});
Result
Default method returns a similar structure: 0|1;3|7;19.56|7
jQuery('.slider').range2DSlider({
printValue:function( val ){
return val[0].toFixed(5);
}
});
Default: false
Default: 0.1
Default:['skin1','skin1']