Slider values

Handles

The number of handles can be set using the start option. This option accepts an array of initial handle positions. Set one value for one handle, two values for two handles.

 
 
$('#slider-handles').noUiSlider({
	start: [ 4000, 8000 ],
	range: {
		'min': [  2000 ],
		'max': [ 10000 ]
	}
});

§

Range

All values on the slider are part of a range. The range has a minimum and maximum value.

 
7914.63
$('#slider-range').noUiSlider({
	start: [ 4000 ],
	range: {
		'min': [  2000 ],
		'max': [ 10000 ]
	}
});
Display the slider value
$('#slider-range').Link('lower').to($('#slider-range-value'));

§

Stepping and snapping to values

The amount the slider changes on movement can be set using the step option.

 
4000.00
$('#slider-step').noUiSlider({
	start: [ 4000 ],
	step: 1000,
	range: {
		'min': [  2000 ],
		'max': [ 10000 ]
	}
});
Display the slider value
$('#slider-step').Link('lower').to($('#slider-step-value'));

§

Non-linear sliders

Advanced Feature

noUiSlider offers some powerful mechanisms that allow a slider to behave in a non-linear fashion. You can create sliders with ever-increasing increments by specifying the value for the slider at certain intervals. Note how the handle in the example below starts at 30% of the slider width, even though 4000 is not 30% of the span between 2000 and 10000.

 
4000.00
$('#slider-non-linear').noUiSlider({
	start: [ 4000 ],
	range: {
		'min': [  2000 ],
		'30%': [  4000 ],
		'70%': [  8000 ],
		'max': [ 10000 ]
	}
});
Display the slider value
$('#slider-non-linear').Link('lower').to($("#slider-non-linear-value"));

§

Stepping in non-linear sliders

For every subrange in a non-linear slider, stepping can be set. Note how in the example below the slider doesn't step until it reaches 500. From there on, it changes in increments of 500, until it reaches 4000, where increments now span 1000.

 
500.00
$('#slider-non-linear-step').noUiSlider({
	start: [ 500, 4000 ],
	range: {
		'min': [     0 ],
		'10%': [   500,  500 ],
		'50%': [  4000, 1000 ],
		'max': [ 10000 ]
	}
});
Display the slider value
$('#slider-non-linear-step').Link('lower').to($('#slider-non-linear-step-value'));

§

Snapping between steps

When a non-linear slider has been configured, the snap option can be set to true to force the slider to jump between the specified values.

 
0.00 500.00
$('#slider-snap').noUiSlider({
	start: [ 0, 500 ],
	snap: true,
	connect: true,
	range: {
		'min': 0,
		'10%': 50,
		'20%': 100,
		'30%': 150,
		'40%': 500,
		'50%': 800,
		'max': 1000
	}
});
Display the slider value
$('#slider-snap'


http://refreshless.com/nouislider/slider-values/

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值