GithubHelp home page GithubHelp logo

sanchit94 / range-touch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dwyl/range-touch

1.0 2.0 0.0 20 KB

:iphone: Use HTML5 range input on touch devices (iPhone, iPad & Android) without bloatware!

License: MIT License

JavaScript 100.00%

range-touch's Introduction

range-touch

Lets you use HTML5 range input on touch devices
(iPhone, iPad & Android) with a single 2kb JS file (no bloatware)!

Requirements

  1. Let touch devices interact with the <input type="range"> element
  2. Do not force people to use any extra styles or script.
  3. Do not modify markup on the page (other scripts do wierd things!)
  4. Degrade gracefully for people with JavaScript disabled (desktop only)
  5. Works with JQuery [96kb] or Zepto [26kb]

Results

iPhone (Safari Mobile iOS 7)

"range-touch iPhone"

Android (Samsung Galaxy S3 - Default Browser 4.2)

"range-touch Android"

iPad (Safari Mobile iOS 7)

"range-touch iPad"


Background

Today I had to add a range ("slider") to our (HTML5) iPad App.
Unfortunately, at the time of writing, Mobile Safari does not support (touch/drag) <input type="range"> ... so I had to search.

Why Not Use JQuery UI...?

A (non-technical) person in the office asked (in patronizing tone):

"Why don't you just use Jquery UI Slider...?" http://jqueryui.com/slider/

Our project does not include JQuery UI I was reluctant to add it just for the slider feature.
jquery-ui-1.10.3.js is 436kb!! Even the minified version jquery-ui.min.js is a whopping 228kb and you also need the CSS file (another 32kb): jquery-ui.css (So unless you need several of Jquery UI's features, loading 260kb on a mobile device is going to be painfully slow!)

I tried building a custom JQuery UI script with just the bare essentials:
http://jqueryui.com/download/ but this was still 140kb+!

Research

My first search for a solution took me to StackOverflow:

But none of the answers solved the problem satisfactorily. All of them require a CSS file which overrides styles we have in our project! We need a lightweight solution that only adds touch support and no styles!

Alternatives

Bibliography

range-touch's People

Contributors

nelsonic avatar nkamc avatar rupl avatar iteles avatar vovimayhem avatar

Watchers

James Cloos avatar Sanchit Sharma avatar

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.