HTML5, CSS3, jQuery, JSON, Responsive Design...

React Bootstrap Slider component

Michael Brown   March 1 2015 10:29:07 PM
I've just written a ReactJS, wrapper for the HTML5 input type=”range” slider component, but using [seiyria’s Bootstrap Slider component] (https://github.com/seiyria/bootstrap-slider) as a polyfill where the HTML5 version is not available (IE 9) or otherwise suffers from a problematic implementation (any other version of IE).

The code and full documentation is available on Github.  There's a demo available too.

Overview

I like the HTML5 native range control, especially how easy it is manipulate via ReactJS, my current favourite JavaScript library.  (I'll be writing a lot more about React in future.)  You set up an HTML5 range control like so:

<input type="range" value="20" min="0" max="100" step="10">


This will give a slider control, ranging from 0 to 100 in steps of 10, with a starting value of 20.  Nice and easy!

Here’s how the native JavaScript control is rendered in my ReactJS plug-in:
render: function () {
   return (
        <input id="mySlider"
           type="range"
           value={this.props.value}
           min={this.props.min}
           max={this.props.max}
           onInput={this.props.handleChange}
           step={this.props.step} />
       );
}


It’s about as simple a rendering as you could want in React. You’d pass some props into your component, and render them as the corresponding attributes on the input field. Sweet as!
But knock me down with a feather if there aren’t problems with IE.


Internet Explorer Problems

The first problem is that input type="range" element simply isn't supported on IE 9 and below. It will actually display as a type=”text” element, so instead of slider, you’ll get a text box with a number in it.  This is what prompted me to create a React control that would fall back to the Bootstrap Slider for browsers that didn’t support the native HTML5 element.

The second problem is that IE10 and 11, where the control does display, doesn't respond correctly to right events when you need to track the slider value being changed.  I go into more detail on that on my Github page.  I probably could have worked around that one, but ran into my third and final problem with IE.

The third problem in IE is that the HTML5 range control looks like crap!  It’s not just ugly, IMHO. It’s inpractical too.  Its handler (the bit on the control that you actually slide) is the same height as the rest of the slider, making it to pick out with your eye, not to mention with your finger if you’re on a tablet. (Thankfully, the latter would only ever be an issue on Microsoft tablets, of which there's next to zero in the real world).

In the end, I made an executive decision in my React Bootstrap Slider component: I don’t display the native HTML5 slider control on IE. At least not for IE 10 or IE 11.  Maybe it looks better in the new, webkit powered IE 12?  I haven't test this myself.

How to use
You can follow the example code in the app.jsx file on the Github page to see how to use.  The component is called SliderNativeBootstrap. Here’s an example of how you might call it in your ReactJS’s render method:

<SliderNativeBootstrap
         value={this.state.currentValue}
         handleChange={this.changeValue}
         step={this.state.step}
         max={this.state.max}
         min={this.state.min} />
.

The value, step, max and min parameters should be self-explanatory. handleChange is the callback method that will be called when the slider actually changes. (NB: this is the onInput event for the native HTML5 control, and the “change” event for the Bootstrap slider.)

Forcing the Bootstrap version all the time
An optional parameter is polyfill. When set to true (the default if you leave the parameter out) the component acts as I’ve described it above, i.e. displaying the HTML5 native slider for these browsers that support it properly, and the Bootstrap version for those that don’t. If you want to force the use of the Bootstrap slider for all browsers then you should set this parameter to false, like so:

<SliderNativeBootstrap
       polyfill={false}
       value={this.state.currentValue}
       handleChange={this.changeValue}
       step={this.state.step}
       max={this.state.max}
       min={this.state.min} />

Demo
Is here.
On load, the slider range is 1,000 to 20,000 with a step of 1,000.
Click on the Change axes! button, and the slider range changes from 0 to 2,000 with a step of 100


Update 11/03/2015

Now available on React Components.
Comments

1cghgjh  03/24/2017 6:24:18 AM  React Bootstrap Slider component

Engineering, Agriculture and Medical Common Entrance Test (EAMCET) is conducted by Jawaharlal Nehru Technological University Kakinada on behalf of APSCHE.

{ Link }

2gambar tahun baru  11/03/2017 2:20:58 PM  React Bootstrap Slider component

go to our website for more information https://www.selamattahunbaru2018.org/

3Happy New Year Wishes  12/18/2017 8:10:49 AM  React Bootstrap Slider component

The Christmas season can quickly become filled up with shopping and cooking and eating and gathering, but at the root

of it all is something far more important: loving. Christmas is a season of hospitality and giving. It is a season

that urges people to put their friends, family, and community in front of selfish needs to help spread joy and hope.

Now what doesn't sound nice about that?

https://best-quotes.org/

merry christmas images hd

https://best-quotes.org/

happy new year 2018 wishes

https://best-quotes.org/

happy new year 2018 quotes </a>

4TS Inter Results 2018  12/19/2017 1:03:25 AM  React Bootstrap Slider component

Board of Secondary Education Andhra Pradesh is going to release Xth class Time table for the session of

2016-17. The private and regular students informed that they can check and download tenth class date sheet

from official website. Every year large number of students attempt to appear in BSEAP to get Admission for

secondary Education school. Students who are going to appear in 10th class Exam, they can see their AP SSC

Time Table 2018 as early as possible.

5Jio Phone Booking  12/19/2017 2:08:37 AM  React Bootstrap Slider component

Reliance Jio is giving numerous telecom offers least expensive costs. Beforehand they have propelled Jio 4G with the

least expensive plans and this choice has made a great deal of clients for Jio. Reliance has as of now brought LYF

mark smartphones into the market, yet now it is said that it will present another scope of smartphones at low budget

plans into the market.

https://jiophone4g.com/jio-prebooking/jio-phone-4g-free-online-booking-registration-at-rs-1500-refund-deposit

jio phone booking

https://jiophone4g.com/jiophone/jio-phone-booking-status-delivery-order-tracking-online

jio phone tracking

https://jiophone4g.com/jio-prebooking/jio-phone-4g-free-online-booking-registration-at-rs-1500-refund-deposit

jio phone 4g

6AP 10th Time Table 2018  12/19/2017 2:47:39 AM  React Bootstrap Slider component

Andhra Pradesh Board of Intermediate Education has released the Inter 1st & 2nd Year annual examination time table.

The Board is the conducting authority which will be given the exam schedule for Students who are enrolled the

Intermediate regular and vocational courses through the AP Intermediate Board affiliated colleges in Andhra pradesh

state for academic session 2017-2018.

https://jntuk.net/datesheets/goa-hssc-time-table-2018-12th-goa-board-time-table-2018

Goa HSSC Time Table 2018

https://jntuk.net/datesheets/karnataka-2nd-puc-exam-time-table-2018

Karnataka 2nd PUC Exam Time Table 2018

https://jntuk.net/datesheets/assam-hs-exam-routine-2018-ahsec-12th-final-exam-time-table

Assam HS Exam Routine 2018

About