Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rangetouch

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangetouch

A super tiny library to make input type='range' sliders work better on touch devices

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
93K
decreased by-15.08%
Maintainers
1
Weekly downloads
 
Created
Source

RangeTouch

A super tiny library to make <input type="range"> sliders work better on touch devices.

Donate to support RangeTouch

Checkout the demo

Why?

While building plyr I noticed how bad the experience was trying to use <input type="range"> is on a touch device (particularly iOS). Touching the track on a desktop will jump the thumb handle to that point. However on some touch devices this simply focuses the input and to adjust the value you need to touch and drag the handle. This is something that I can't help but feel will eventually be fixed by the browser vendors but for now, you can use RangeTouch to fill that gap.

Features

  • No setup required, just include the script
  • Less than 1KB minified and gzipped
  • No dependencies (written in "vanilla" JavaScript)

Quick setup

To use RangeTouch, you just need to add rangetouch.js (either from the /dist (minified) or /src/js (unminified) folders) before the closing </body> tag like so:

<script src="/path/to/rangetouch.js"></script>

It will automatically bind to all <input type="range"> elements, even newlt injected ones.

CDN

You can even load RangeTouch from our CDN if you'd like:

<script src="https://cdn.rangetouch.com/1.0.2/rangetouch.js"></script>

Node Package Manager (NPM)

npm version

Using NPM, you can grab RangeTouch:

npm install rangetouch

https://www.npmjs.com/package/rangetouch

Bower

Bower version

If bower is your thang, you can grab RangeTouch using:

bower install rangetouch

http://bower.io/search/?q=rangetouch

More info on setting up dependencies can be found in the Bower Docs

Configuration

If you're customizing your range inputs (easily done - see the demo for an example) and you change the size of the thumb handle, you should specify (in pixels) this after including the script:

window.rangetouch.set("thumbWidth", 15);

This value is used as part of the calculation to determine the value the users selects when touching the range track. Unfortunately as JavaScript can't access the shadow DOM, this value can't be automatically determined. I would recommend customisation (and setting the size of the thumb) given all OS and browser combinations seem to render the control differently (as per usual).

If you want to disable RangeTouch for a particular input, add the rangetouch--disabled class name to the element.

Issues

If you find anything weird with RangeTouch, please let us know using the GitHub issues tracker.

Author

RangeTouch is developed by @sam_potts / sampotts.me

Donate

RangeTouch costs money to run, not my time - I donate that for free but domains, hosting and more. Any help is appreciated... Donate to support RangeTouch

Thanks

Fastly

Thanks to Fastly for providing the CDN services.

The MIT license.

Keywords

FAQs

Package last updated on 15 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc