1.0.4 • Published 10 years ago

jquery-nstslider v1.0.4

Weekly downloads
224
License
-
Repository
github
Last release
10 years ago

jquery.nstSlider.js

Fully customizable with CSS, Single/Double handles, Touch-enabled, IE 7+ Compatibility, Custom Digit Rounding, Non linear step increments!

Build Status

Example

Initialize with:

$(".mySlider").nstSlider({
    "left_grip_selector": ".leftGrip",
    "right_grip_selector": ".rightGrip",
    "value_bar_selector": ".bar",
    "value_changed_callback": function(cause, minValue, maxValue, prevMinValue, prevMaxValue) {
        // show the suggested values in your min/max labels elements
    }
});

Destroy with:

$(".mySlider").nstSlider('teardown');

Demo

For live demos please visit the project webpage:

http://lokku.github.io/jquery-nstslider/

For a Quick Start have a look at the source html of the following file:

https://github.com/lokku/jquery-nstslider/blob/master/demo/index.html

Options

OptionTypeDefaultDescription
animating_css_classstringnst-animatingthe css class to be used when the slider is to be animated (this happens when a certain min/max value is being set for example).
touch_tolerance_value_bar_xnumber15the horizontal tolerance in pixels by which a handle of the slider should be grabbed if the user touches outside the slider bar area.
touch_tolerance_value_bar_ynumber30the vertical tolerance in pixels by which a handle of the slider should be grabbed if the user touches outside the slider bar area.
left_grip_selectorstring.nst-slider-grip-leftthe selector of the left grip handle. The left grip element must exist in the page when the slider is initialized.
right_grip_selectorstringundefinedthe selector of the right grip handle. This is optional. A single handler bar is assumed if this selector is not specified.
value_bar_selectorstringundefinedthe selector of the value bar. If not specified assumes a value bar representing the selection is not wanted.
roundingobject or number1the rounding for a certain value displayed on the slider. This rounds the values returned in the value_changed_callback as roundedValue : int(actualValue / rounding) * rounding. The rounding parameter can be a number (i.e., fixed rounding) or can depend on actualValue (i.e., dynamic rounding). To perform dynamic rounding an object must be passed instead of a value. For example, passing rounding : { '1' : '100', '10' : '1000', '50' : '10000' } will use rounding = 1 when actualValue <= 100, rounding = 10 when 100 < actualValue <= 1000 and so on...
value_changed_callbackfunctionfunction(cause, curMin, curMax, prevMin, prevMax) { return; }a callback called whenever the user drags one of the handles.
user_mouseup_callbackfunctionfunction(vmin, vmax, left_grip_moved) { return; }a callback called whenever the mouse button pressed while dragging a slider grip is released
user_drag_start_callbackfunctionfunction () { return; }a callback called before the user drags one of the handles

Methods

MethodArgumentDescription
get_range_minNonereturn the current minimum range of the slider
get_range_maxNonereturn the current maximum range of the slider
get_current_min_valueNonereturn the current minimum value of the slider
get_current_max_valueNonereturn the current maximum value of the slider
is_handle_to_left_extremeNonereturn a boolean indicating whether or not the left handler is moved all the way to the left
is_handle_to_right_extremeNonereturn a boolean indicating whether or not the right handler is moved all the way to the right
refreshNoneforce a refresh of the slider
disableNonedisable the slider (i.e., user cannot move the handles)
enableNoneenable the slider (i.e., user can move the handles)
is_enabledNonereturn a boolean indicating whether or not the slider can be moved by the user
set_positionmin: number, max: numberset the handles at the specified min and max values
set_step_histogramhistogram : array of numbersuse a non-linear step increment for the slider that is stretched where the histogram provided counts more items
unset_step_histogramNoneuse a linear scale of increments for the slider
set_rangerangeMin : number, rangeMax : numberset the minimum and the maximum range of values the slider
set_roundingrounding: number or objectset the rounding for the slider
get_roundingNonereturn the current rounding of the slider
teardownNoneremove all data stored in the slider

Dependencies

jQuery 1.6.4+

License

Copyright (c) 2014 Lokku Ltd.

Licensed under the MIT license.