Giter Club home page Giter Club logo

bootstrap-slider's Introduction

bootstrap-slider Build Status

Originally began as a loose "fork" of bootstrap-slider found on http://www.eyecon.ro/ by Stefan Petre.

Over time, this project has diverged sigfinicantly from Stefan Petre's version and is now almost completely different.

Please ensure that you are using this library instead of the Petre version before creating issues in the repository issue tracker!!

Starting with major release 11.0.0, we only support Bootstrap 4!

Installation

Want to use bower? bower install seiyria-bootstrap-slider

Want to use npm? npm install bootstrap-slider

Want to get it from a CDN? https://cdnjs.com/libraries/bootstrap-slider

Basic Setup

Grab the compiled JS/CSS (minified or non-minified versions) from the /dist directory, load them into your web page, and everything should work!

Remember to load the plugin code after loading the Bootstrap CSS and JQuery.

JQuery is optional and the plugin can operate with or without it.

Look below to see an example of how to interact with the non-JQuery interface.

Supported Browsers

We only support modern browsers!!! Basically, anything below IE10 is not compatible with this plugin!

Examples

You can see all of our API examples here.

Using bootstrap-slider (with JQuery)

Using .slider namespace

Create an input element and call .slider() on it:

// Instantiate a slider
var mySlider = $("input.slider").slider();

// Call a method on the slider
var value = mySlider.slider('getValue');

// For non-getter methods, you can chain together commands
	mySlider
		.slider('setValue', 5)
		.slider('setValue', 7);

Using .bootstrapSlider namespace

Create an input element and call .bootstrapSlider() on it:

// Instantiate a slider
var mySlider = $("input.slider").bootstrapSlider();

// Call a method on the slider
var value = mySlider.bootstrapSlider('getValue');

// For non-getter methods, you can chain together commands
	mySlider
		.bootstrapSlider('setValue', 5)
		.bootstrapSlider('setValue', 7);

Using bootstrap-slider (via data-provide-API)

Create an input element with the data-provide="slider" attribute automatically turns it into a slider. Options can be supplied via data-slider- attributes.

<input
	type="text"
	name="somename"
	data-provide="slider"
	data-slider-ticks="[1, 2, 3]"
	data-slider-ticks-labels='["short", "medium", "long"]'
	data-slider-min="1"
	data-slider-max="3"
	data-slider-step="1"
	data-slider-value="3"
	data-slider-tooltip="hide"
>

What if there is already a slider plugin bound to the JQuery namespace?

If there is already a JQuery plugin named slider bound to the JQuery namespace, then this plugin will provide an alternative namespace bootstrapSlider and will emit a console warning telling you the slider namespace has already been taken and will encourage you to use the alternate namespace instead. If the slider namespace is available however, the bootstrapSlider namespace will not exist.

// Instantiate a slider
var mySlider = $("input.slider").bootstrapSlider();

// Call a method on the slider
var value = mySlider.bootstrapSlider('getValue');

// For non-getter methods, you can chain together commands
	mySlider
		.bootstrapSlider('setValue', 5)
		.bootstrapSlider('setValue', 7);

Using bootstrap-slider (without JQuery)

Create an input element in the DOM, and then create an instance of Slider, passing it a selector string referencing the input element.

// Instantiate a slider
var mySlider = new Slider("input.slider", {
	// initial options object
});

// Call a method on the slider
var value = mySlider.getValue();

// For non-getter methods, you can chain together commands
mySlider
	.setValue(5)
	.setValue(7);

Using as CommonJS module

bootstrap-slider can be loaded as a CommonJS module via Browserify, Webpack, or some other build tool.

var Slider = require("bootstrap-slider");

var mySlider = new Slider();

How do I exclude the optional JQuery dependency from my build?

Browserify

Note that the JQuery dependency is considered to be optional. For example, to exclude JQuery from being part of your Browserify build, you would call something like the following (assuming main.js is requiring bootstrap-slider as a dependency):

browserify --im -u jquery main.js > bundle.js

Webpack

To exclude JQuery from your Webpack build, you will have to go into the Webpack config file for your specific project and add something like the following to your resolve.alias section:

resolve: {
    alias: {
         "jquery": path.join(__dirname, "./jquery-stub.js")
    }
}
Encore
    // directory where compiled assets will be stored
    .setOutputPath('public/build/')
    // ...
    webpack-encore config
    ...
;

const config = Encore.getWebpackConfig();
config.resolve.alias["jquery"] = path.resolve(__dirname, 'assets/js/jquery-stub.js');
module.exports = config

Then in your project, you will have to create a stub module for jquery that exports a null value. Whenever require("jquery") is mentioned in your project, it will load this stubbed module.

// Path: ./jquery-stub.js
module.exports = null;

Other

Please see the documentation for the specific module loader you are using to find out how to exclude dependencies.

Options

Options can be passed either as a data (data-slider-foo) attribute, or as part of an object in the slider call. The only exception here is the formatter argument - that can not be passed as a data- attribute.

Name Type Default Description
id string '' set the id of the slider element when it's created
min float 0 minimum possible value
max float 10 maximum possible value
step float 1 increment step
precision float number of digits after the decimal of step value The number of digits shown after the decimal. Defaults to the number of digits after the decimal of step value.
orientation string 'horizontal' set the orientation. Accepts 'vertical' or 'horizontal'
value float, array 5 initial value. Use array to have a range slider.
range bool false make range slider. Optional if initial value is an array. If initial value is scalar, max will be used for second value.
selection string 'before' selection placement. Accepts: 'before', 'after' or 'none'. In case of a range slider, the selection will be placed between the handles
tooltip string 'show' whether to show the tooltip on drag, hide the tooltip, or always show the tooltip. Accepts: 'show', 'hide', or 'always'
tooltip_split bool false if false show one tootip if true show two tooltips one for each handler
tooltip_position string null Position of tooltip, relative to slider. Accepts 'top'/'bottom' for horizontal sliders and 'left'/'right' for vertically orientated sliders. Default positions are 'top' for horizontal and 'right' for vertical slider.
handle string 'round' handle shape. Accepts: 'round', 'square', 'triangle' or 'custom'
reversed bool false whether or not the slider should be reversed
rtl string, bool 'auto' whether or not the slider should be shown in rtl mode. Accepts true, false, 'auto'. Default 'auto' : use actual direction of HTML (dir='rtl')
enabled bool true whether or not the slider is initially enabled
formatter function returns the plain value formatter callback. Return the value wanted to be displayed in the tooltip, useful for string values. If a string is returned it will be indicated in an aria-valuetext attribute.
natural_arrow_keys bool false The natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders, arrow right the righter slider value for a horizontal slider - no matter if the slider was reversed or not. By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value.
ticks array [ ] Used to define the values of ticks. Tick marks are indicators to denote special values in the range. This option overwrites min and max options.
ticks_positions array [ ] Defines the positions of the tick values in percentages. The first value should always be 0, the last value should always be 100 percent.
ticks_labels array [ ] Defines the labels below the tick marks. Accepts HTML input.
ticks_snap_bounds float 0 Used to define the snap bounds of a tick. Snaps to the tick if value is within these bounds.
ticks_tooltip bool false Used to allow for a user to hover over a given tick to see it's value. Useful if custom formatter passed in
scale string 'linear' Set to 'logarithmic' to use a logarithmic scale. Logarithmic scales will be calculated based on the difference between min to max; e.g. (0..10000) (-100..9900) both have a net range of 10001 and will slide in the same net increments.
focus bool false Focus the appropriate slider handle after a value change.
labelledby string, array null ARIA labels for the slider handle's, Use array for multiple values in a range slider.
rangeHighlights array [] Defines a range array that you want to highlight, for example: [{'start':val1, 'end': val2, 'class': 'optionalAdditionalClassName'}].
lock_to_ticks bool false Lock the selection to the values defined at ticks array.

Functions

NOTE: Optional parameters are italicized.

Function Parameters Description
getValue --- Get the current value from the slider
setValue newValue, triggerSlideEvent, triggerChangeEvent Set a new value for the slider. If optional triggerSlideEvent parameter is true, 'slide' events will be triggered. If optional triggerChangeEvent parameter is true, 'change' events will be triggered. This function takes newValue as either a Number, String, Array. If the value is of type String it must be convertable to an integer or it will throw an error.
getElement --- Get the div slider element
destroy --- Properly clean up and remove the slider instance
disable --- Disables the slider and prevents the user from changing the value
enable --- Enables the slider
toggle --- Toggles the slider between enabled and disabled
isEnabled --- Returns true if enabled, false if disabled
setAttribute attribute, value Updates the slider's attributes
getAttribute attribute Get the slider's attributes
refresh options Refreshes the current slider and resets the slider's value to its default value on initial setup. To override this behaviour and instead maintain the slider's current value, pass the optional options parameter with the property useCurrentValue set to true (eg. refresh({ useCurrentValue: true }).
on eventType, callback When the slider event eventType is triggered, the callback function will be invoked
off eventType, callback Removes the callback function from the slider event eventType
relayout --- Renders the tooltip again, after initialization. Useful in situations when the slider and tooltip are initially hidden.

Events

Event Description Value
slide This event fires when the slider is dragged The new slider value
slideStart This event fires when dragging starts The new slider value
slideStop This event fires when the dragging stops or has been clicked on The new slider value
change This event fires when the slider value has changed An object with 2 properties: "oldValue" and "newValue"
slideEnabled This event fires when the slider is enabled N/A
slideDisabled This event fires when the slider is disabled N/A

How Do I Run This Locally?

  • Clone the repository
  • Run nvm use in your Terminal to switch to the proper Node/NPM version
  • Once you are on specified Node version, run npm install
  • Install the Grunt CLI: npm install grunt-cli -g
  • Type grunt dev to launch browser window with Examples page

Grunt Tasks

This plugin uses Grunt as its command-line task runner.

To install the Grunt CLI, type npm install grunt-cli -g.

To execute any of the commands, type grunt <task-name> in your terminal instance.

The following is a list of the commonly-used command line tasks:

  • grunt development: Generates the index.html, compiles the SASS/JS to the /temp directory, and launches the index.html in your system's default browser. As changes are made to source code, the browser window will auto-refresh.
  • grunt production: Generates the /dist directory with minified and unminified assetts.
  • grunt dev: Alias for grunt development
  • grunt prod: Alias for grunt production
  • grunt build: Transpiles JavaScript source via Babel and compiles LESS source to CSS to temp directory.
  • grunt lint: Runs JSLint on the JavaScript source code files, and SASS-Lint on the SASS source code files.
  • grunt test: Runs unit tests contained in /test directory via Jasmine 2.x.x

Version Bumping and Publishing (Maintainers Only)

For versioning rules, we follow the Semver convention.

To do the following release tasks:

  • bump the version
  • publish a new version to NPM
  • update the gh-pages branch
  • push a new dist bundle to the master branch on the remote origin
  • push new tags to the remote origin

Type the following command:

npm run release <patch|minor|major>

If you do not specify a version bump type, the script will automatically defer to a patch bump.

Updating Github.io Page

The Github.io page can be automatically updated by running the following command:

npm run update-gh-pages

This command will handle generating the latest versions of the JS/CSS and index.html page, and push them to the gh-pages branch.

Other Platforms & Libraries

Maintainers

Looking for a Premium UI Kit?

AdminKit is a developer friendly & highly customizable Bootstrap 5 admin template featuring hundreds of UI components, forms, tables, charts and icons. Learn more.

AdminKit - Premium Bootstrap 5 admin template

bootstrap-slider's People

Contributors

cornedor avatar davidlesieur avatar gio-js avatar givized avatar inamiy avatar j0hnsmith avatar jerrylow avatar jespirit avatar jkrehm avatar junchangchen avatar larkinscott avatar lipoczkit avatar mazdermind avatar mediaformat avatar melleb avatar mitsos1os avatar patchman-sebastiaan avatar pmoncunill avatar rahatarmanahmed avatar raulfortes avatar rovolution avatar seiyria avatar serbiant avatar sesh-kebab avatar shnoulle avatar snurby7 avatar viceice avatar zevs777 avatar zonia3000 avatar zsiswick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootstrap-slider's Issues

knockout.js dynamic add

Using knockout.js in a repeating element. When I add an object to the view model, it adds a row to a table where a slider is supposed to render. The error I get in chrome is: "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method".

I have tried to destroy and recreate but no luck. Here is my binding handler where the error occurs.
ko.bindingHandlers.sliderValue = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
$(element).slider('destroy');
$(element).slider({});
$(element).slider('setValue', value())
$(element).on('slide', function (ev) {
value(ev.value);
});
},
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
$(element).slider('setValue', value());
}
};

Keyboard support

  1. When a slider exists in a form, tabbing through fields skips the slider completely. Sliders handles should be "focusable".
  2. Let the slider handle be moved with arrow keys. This would help significantly for large ranges with small steps, since that makes it difficult to select an exact amount.

Move from touch/mouse detection to using Modernizrs pointer events.

Currently my desktop is reporting that it is touchCapable when it is not, making the slider completely unusable. According to this StackOverflow question checking for a pointer seems to encompass both touch and mouse events.

I should add that I don't know what this means for previous versions to make this change, though. @rovolution, do you know anything about this subject?

Documentation updates

Hey seiyria,

I was looking through the documentation page you added and saw that a couple of things were missing.

  • Adding in a description for the 'destroy' method to the Functions table

    slider('destroy') - Properly removes and cleans up slider instance
    
  • A list of what properties can be set via HTML5 data attributes (and what the data attribute is). We could just copy the Markup section straight from the original example - http://www.eyecon.ro/bootstrap-slider/.

That's all! Otherwise it looks good

LESS file needs the mixins library

bootstrap-slider.less imports a mixins library not included with the ZIP from GitHub:

@import 'mixins.less';

Could we include that library or at least reference which library is used?

Jquery Ui

My jquery ui slider is overriding this. Anyone ran into this issue?

Disable slider

Is there any way to disable the slider to one point ? Right now I'm just hiding the slider in order to lock it.

  • ported from another repo that was meant to be posted here.

Reverse start position

Is there any way, in this case with a horizontal slider, for the starting value (1) to start at the right hand side, and as it increases in value the slider moves from the right to left?

Would be handy for there to be a "reverse" option.

Slider getValue, setValue does not seem to work

Hi,

The setValue and getValue functions do not seem to work. They are always returning a new instance of the slider object and do not affect in any way the slide itself.

For one of my projet, I need a slider to control a large carousel and everything is working fine except when the carousel is setting the new position of the slider.

You can demo it here: http://jsfiddle.net/vallieres/Z6CyV/

<iframe width="100%" height="300" src="http://jsfiddle.net/vallieres/Z6CyV/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

Tick Marks?

Any way to create tick marks on the slider based on the step by default (or alternatively as one posted suggested based on an ordinal set of values or labels?)

Addition of grunt tasks?

Hi seiyria,

I was thinking of adding in some NPM grunt tasks to ease the development process and generate an optimized production version of the code:

'development' task

Launches an index.html test page on the user's default browser, and then starts grunt-watch to look for changes on the .less file and .js file.

  • When the .less file changes, it will automatically compile the .less file to .css
  • When the .js file changes, it will automatically run JSHint on the code to see if it follows best practices

'production' task

  • Compiles .less to .css
  • Checks .js to see if it passes JSHint, and then runs uglify on it to create minified and concatenated version for production use.

I think this would really be nice to have to allow users to easily launch a development environment in addition to generating a production version of the code. Let me know what your thoughts are.

Thanks!
-Rohit K

[request] Make File Names Consistent

Please make the file names consistent. Currently the JavaScript file is called bootstrap-slider but the CSS file is called slider. This is confusing and unexpected. Please change the CSS file name to be consistent.

Tips value incorrect

I am using a range slider but the tip's value does not match the actual value.

I subscribed the 'slideStop' event and inside the event, I print the result of $(this).val() to the console.

This bug occurs for both lower value and upper value. Especially when I try to make a small movement.

setValue

Thank you all.
How do I set min and max values for a range slider?
I would like the slider's min (or max) to slide to a value set by the user using an input field. Is this possible?

Squashing commits before pushing to remote

hi seiyra,

I just saw the recent commits you made to the repo.

It all looks good!

I just have one suggestion...when you are making changes and committing to your local repository, before pushing those changes back to the master branch at the 'origin' remote, you should squash them locally into a single commit and then push up to the remote master branch. It makes the commit history look much cleaner.

Here is a link to a tutorial: http://davidwalsh.name/squash-commits-git

I wouldn't advise doing it now (people may be basing work off of the current branch history, so rebasing the current master branch could potentially mess up their topic branch and prevent them from submitting a proper pull request), but its just something to keep in mind when making updates in the future.

Thanks!

Strange slider width

I use the slider inside a <div class="span8"> but I didn't specify the width of the <input>.
However, the slider does not fully occupy the parent

.
If I set <input style="width:100%">, the slider just simply overflow the parent and its the width == the screen width.
Besides, there is a outer <div class="row-fluid"> since I am using bootstrap's 2.3.2 & its responsive design feature.
Here is my code

<div class="row-fluid">
  <span id="budget-min" class="span2" style="text-align:right; padding-right:20px">10</span>
  <div id="budget-slider-container" class="span8">
    <input id="budget-slider" type="text" value="[10,100]" data-slider-min="10" data-slider-max="100" data-slider-step="10" data-slider-value="[10,100]" data-slider-orientation="horizontal" data-slider-selection="after" data-slider-tooltip="hide">
  </div>
  <span id="buget-max" class="span2">100</span>
</div>

For reference only:
I use chrome's developer tool to measure the width of the div.span8 and the div.slider.slider-horizontal.
div.span8 = 304px
div.slider.slider-horizontal = 220px

Refactoring spec directory structure

As the functionality of the slider has begun to grow, I realize that the initial structure we set up for the test specs (only 3 separate files) will become pretty unmaintainable in the long run.

Therefore, I propose that we refactor the spec directory and set it up the following way:

  • A directory for each of the spec types (elementDataAttributes, events, publicMethods)
  • Within the elementDataAttributes directory, we will have a spec file for each data attribute
  • Within the events directory, we will have a spec file for each event type
  • Within the publicMethods directory, we will have a spec file for:
    • each of the initialization options
    • each of the methods

Thoughts? @seiyria

Allow update of the Slider

$("#slider").slider()
But you can't after do that :
$("#slider").slider({max: 3})

This is patch allowing that :
diff --git a/js/bootstrap-slider.js b/js/bootstrap-slider.js
index 68e750d..a4e823f 100644
--- a/js/bootstrap-slider.js
+++ b/js/bootstrap-slider.js
@@ -21,6 +21,14 @@

    var Slider = function(element, options) {
            this.element = $(element).hide();
  •    updateSlider = false
    
  •    parent = this.element.parent()
    
  •    if (parent.hasClass('slider') == true) {
    
  •        updateSlider = true
    
  •        this.picker = parent
    
  •    } else {
            this.picker = $('<div class="slider">'+
                                                    '<div class="slider-track">'+
                                                            '<div class="slider-selection"></div>'+
    

    @@ -31,6 +39,8 @@
    '')
    .insertBefore(this.element)
    .append(this.element);

  •           }
    
    •       this.id = this.element.data('slider-id')||options.id;
            if (this.id) {
                    this.picker[0].id = this.id;
      

    @@ -145,6 +155,17 @@
    } else {
    this.tooltip.addClass('hide');
    }
    +

  •           if (updateSlider == true) {
    
  •        var val = this.calculateValue();
    
  •        this.element
    
  •            .trigger({
    
  •                type: 'slide',
    
  •                value: val
    
  •            })
    
  •            .data('value', val)
    
  •            .prop('value', val);
    
  •    }
    };
    
    Slider.prototype = {
    

    @@ -377,9 +398,9 @@
    var $this = $(this),
    data = $this.data('slider'),
    options = typeof option === 'object' && option;

  •                   if (!data)  {
    
  •                           $this.data('slider', (data = new Slider(this, $.extend({}, $.fn.slider.defaults,options))));
    
  •                   }
    
  •        $this.data('slider', (data = new Slider(this, $.extend({}, $.fn.slider.defaults,options))));
    
    •               if (typeof option == 'string') {
                            data[option](val);
                    }
      

slideChange event not working

Perhaps I'm using it incorrectly, but cannot seem to get the 'slideChange' event to fire and call my function... do you have a small snippet that demonstrates it working !?

setValue not setting - throwing error on validateInputValue

Using:

$('.class-slider-box .slider').slider('setValue', 5);

I get an error:

Uncaught TypeError: Object [object global] has no method 'validateInputValue'

This corresponds to: bootstrap-slider.js:414 or

var tempValue = this.validateInputValue(val);

Don't believe there's anything wrong with my set-up. Using jQuery 2.0.3, Bootstrap 3. Slider has initialised correctly and is in use.

Anything you can advise?

Can't move slider

Hi,

I can't move sliders under Chrome 23.0. This is a bug present also in original version.

See you

Cursor on disabled slider

When a slider is disabled, the cursor on the track and the handle remain as "pointer".

One could add a "cursor: default;" after lines 75 and 78 in bootstrap-slider.less

Thanks for the great work done here !

Disable a value

Thanks for all your work on a great slider. I have an unusual case though where I need to disable a single value somehow.

An example illustrates this best.

Values: 1, 2, 4

I am not sure how to achieve this though. Thanks!

Bootstrap 3 support

Does it supports Bootstrap 3? I tried and couldn't use it:

imagem

I am trying to use it with months and years. example:

November 2012 November 2013
--[ ]------------------------------------------------------------------------------------------[ ]--

Is it possible?

Thanks.

Width 4px Inside Bootstrap Tabs

If i dont specify any width for the tab1 its working fine so i have copied same code to tab2 but the slider is having strange width i have used firebug and i see it is having 4px of width with classes slider slider-horizontal .
tab1
tab2

Two tooltips for range sliders

For range sliders, it'd be nice to have the option of showing two independent tooltips, one over each handle. This looks cleaner in some contexts, especially when the tooltips are set to always show.

Include LESS compilation in Gruntfile

The stylesheet in less/slider.less isn't actually used or compiled. Might make future improvements easier and is just in general nice to have.

Concerns:
Changes to Bootstrap may break the LESS. (However, there are only two variables and one mixin used right now.)

Tests to create

This issue is open to decide what tests should be included. I think we should probably have test coverage for:

Add test that checks for console calls

There shouldn't be any console.log calls in the slider. It might be reasonable to have console.error and console.warn though. I'm not sure what would be for the best. This can be done with grunt-remove-logging.

Implement a test for 'step'

currently the step attribute needs a test, as per #14.
This is needed in both ElementDataAttributesSpec and PublicMethodsSpec

A possible way to do this would be to implement a stepUp() and stepDown() function that apply the step amount to the current value, and test these functions instead.

"Click" on slider produces wrong value

When I slide the slider, the little tooltip goes from 0 to 100 beautifully (my min/max). When I click somewhere else on the slider, the dot (or triangle, square) moves to that place, but the tooltip number is wrong.
image
image

data attributes issue

On lines 79-88 this code doesn't seem to be working. It's not considering undefined, which seems to be returned by line 80 when data attributes are not set.

    ['min', 'max', 'step', 'value'].forEach(function(attr) {
        var val = el.data('slider-' + attr);
        if (val === null || val === '') {
            val = options[attr];
        }
        if (val === null || val === '') {
            val = el.prop(attr);
        }
        this[attr] = val;
    }, this);

Could it be better written as... ?

    ['min', 'max', 'step', 'value'].forEach(function(attr) {
        this[attr] = el.data('slider-' + attr) || options[attr] || el.prop(attr);
    }, this);

[Bug] Position Tooltip Before Show

To Replicate:

Setup: Give slider a percentage width.

  1. Resize browser window, or slider container so that its width changes.
  2. Drag Slider Handle.

Result: Tooltip appears at old location for a moment before being correctly positioned/centred based on new width.

Fix: Calculate tooltip position before showing it.

Adding .slider with a class name?

Hi there!

I found out about this awesome bootstrap slider today and implemented into my project, it looks great!

However, I have only encountered one issue: if I do this:

jQuery('#slider-id1').slider({})
jQuery('#slider-id2').slider({})

it works great.

But I wanted to do the following: have several slides in a list and not give them an id; instead use a class.

So, I have 2 inputs like this:

And then the jQuery call:

jQuery('.manual-effect-filter').slider({
});

But then only the 1st slider works :-( The 2nd one won't move, and it looks like it's getting the value from the 1st one when I slide it

slider

Is this an expected behaviour? Is there a workaround? Or am I doing something wrong?

Thanks so much for your help, and for this awesome library!

[Usability] Focus handle on mousedown

This would help a lot when combined with the newly implemented keyboard support.

I feel that people will start dragging a handle with the mouse. If it's difficult to drop the handle exactly where you want it (because of a large range), it would be nice to instantly use the keyboard to make minor adjustments.

As it stands, you have to click somewhere before the slider and tab over to it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.