All Projects → samuelcarreira → webkit-input-range-fill-lower

samuelcarreira / webkit-input-range-fill-lower

Licence: MIT License
Customize/styles the native HTML input range controls like the ::-ms-fill-lower property on IE - Pure JS

Programming Languages

HTML
75241 projects
typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to webkit-input-range-fill-lower

plasmolysis
[WIP] 探索同构开发新范式的可能性
Stars: ✭ 12 (-29.41%)
Mutual labels:  controller
lazynite
A PC remote controller for YouTube and Twitch
Stars: ✭ 45 (+164.71%)
Mutual labels:  controller
debian-lightdm-webkit-greeter
LightDM Webkit Greeter for Debian
Stars: ✭ 20 (+17.65%)
Mutual labels:  webkit
pcb-ws2812-wifi-controller
WiFi Controller for WS2812 LED Stripes
Stars: ✭ 48 (+182.35%)
Mutual labels:  controller
libwinmedia
[Archived] A cross-platform simple media playback library for C/C++.
Stars: ✭ 35 (+105.88%)
Mutual labels:  webkit
Interstellar
Cross-platform desktop apps in F# using web tech - https://www.nuget.org/packages/Interstellar.Core/
Stars: ✭ 32 (+88.24%)
Mutual labels:  webkit
openstack-cloud-controller-manager
This repository has moved to https://github.com/kubernetes/cloud-provider-openstack
Stars: ✭ 17 (+0%)
Mutual labels:  controller
ControllerAutowire
[DEPRECATED] Use Controller autowiring by default since Symfony 3.3
Stars: ✭ 24 (+41.18%)
Mutual labels:  controller
webviewhs
🌐 A Haskell binding to the webview library created by Serge Zaitsev.
Stars: ✭ 109 (+541.18%)
Mutual labels:  webkit
VGamepad
Server-Side Installer & Instructions
Stars: ✭ 19 (+11.76%)
Mutual labels:  controller
phpstan-symfony
*DEPRECATED* Symfony extension for PHPStan
Stars: ✭ 42 (+147.06%)
Mutual labels:  controller
aranya
Control all kinds of devices with Kubernetes
Stars: ✭ 16 (-5.88%)
Mutual labels:  controller
SPStorkController
Now playing controller from Apple Music, Mail & Podcasts Apple's apps.
Stars: ✭ 2,515 (+14694.12%)
Mutual labels:  controller
Alfred ShadowsocksController
ShadowsocksX controller for Alfred
Stars: ✭ 70 (+311.76%)
Mutual labels:  controller
CodeDroneDIY
The most simple, but working, quadricopter flight controller from scratch, using Arduino Uno/Nano.
Stars: ✭ 68 (+300%)
Mutual labels:  controller
sdram-controller
Generic FPGA SDRAM controller, originally made for AS4C4M16SA
Stars: ✭ 45 (+164.71%)
Mutual labels:  controller
retrokit
🕹️ Bring back the old Web(Kit) and make it secure
Stars: ✭ 39 (+129.41%)
Mutual labels:  webkit
redux-saga-controller
A tool to simplify work with react, redux and redux-saga
Stars: ✭ 18 (+5.88%)
Mutual labels:  controller
SwitchXBOXController
Turn your Nintendo Switch into an XBOX360 controller to play on your Windows computer
Stars: ✭ 46 (+170.59%)
Mutual labels:  controller
diy-iidx
Arduino Leonardo code to make a Beatmania controller. Included CAD files for laser cutting materials.
Stars: ✭ 35 (+105.88%)
Mutual labels:  controller

WebKit Input Range Fill Lower Hack

Customize the native input range controls like the ::-ms-fill-lower property on WebKit browsers

License

Screenshot

New Version 3.x Notice

Because of the increasing interest in this "library", I decided to completely rewrite it.

WARNING: the old version isn't compatible with this one. If you want to use the older version you can download it from here

Key Features

  • Uses native HTML input range type (more accessibility, native behavior)
  • Doesn't require anymore the external CSS new version
  • Multiple elements new version
  • Customizable styles (solid color or gradient) new version
  • Written in TypeScript new version
  • Pure / vanilla JavaScript (no jQuery)
  • Lightweight (3.6kB minified ~1.3kB gzipped)

View the sample page: https://samuelcarreira.github.io/webkit-input-range-fill-lower

Quick Usage

You only need to follow 4 simple steps to start using this module:

  1. Download the script file from the dist folder or releases (minified file: webkit-input-range-fill-lower.min.js)
  2. Add the input range controls on your web page. Each control needs a unique ID and the max value
// valid
<input type="range" min="0" max="10" value="10" id="your-custom-id">

// invalid: no ID
<input type="range" min="0" max="10" value="10">

// invalid: no max value
<input type="range" id="your-custom-id">
  1. Call the library after the page is loaded
document.addEventListener('DOMContentLoaded', () => {
  const myRanges = new WebkitInputRangeFillLower({selectors: ['your-custom-id', 'your-custom-id2'], angle: 90, gradient: 'rgba(238,174,202,1) 0%, rgba(198,180,216,1) 74%, rgba(148,187,233,1) 100%'});
});
  1. (Optional) You can customize the input element on the page stylesheet. View the index.html or the sample page source code to learn more

WebkitInputRangeFillLower(options)

Class options

Property Type Required Description
selectors string[] yes List of HTML ID attributes. If you want to select multiple selectors use an array like ['your-custom-id', 'your-custom-id2'], single selector can be defined with a simple string selectors: 'your-custom-id'
angle number no Gradient angle (0-360 degrees). Default value: 90 (only in gradient color)
color string no CSS solid color. With can use any CSS color format: hexadecimal, description, rgb or rgba
gradient string no CSS gradient color definition. The default value is the gradient #0ABFBC, #FC354C. You can set the position of the color on the gradient like rgba(238,174,202,1) 0%, rgba(198,180,216,1) 74%, rgba(148,187,233,1) 100%

Compatibility

As the name indicates, this "library" was written to be compatible with the WebKit engine browsers (Google Chrome, Opera, New Microsoft Edge, etc.). On Mozilla Firefox you cannot expect the same results even with the -moz-range-progress added (read more here )

compatibility

Motivation and history

I've created this "hack" because I wanted to use a range slider on my Electron App (a music player with volume control). After I tried some plugins like the rangeslider.js I decided to write something more lightweight and more easy to use. As Electron apps use Chrome (WebKit) as the render engine, I didn't add any compatibility with other browsers/fallbacks to older versions (on the new 3.0 version I've added the Mozilla firefox and Microsoft Internet Explorer 'fallback' property).

How this 'hack' works

This 'hack' uses the ::-webkit-slider-runnable-track CSS pseudo-element (which represents the "track" or the groove in which the indicator slides of an input type="range"). Because you cannot access this property directly on an inline CSS style, this library needs to write a custom style tag directly on the page header where it's set the custom styles and the background style. Because you can "set the size" of the background (when you use a linear gradient), this 'library' calculates the percentage of the value on the input range element and adjusts the size of the background to that percentage. Each time the input range value is changed, the event listener updates the background-size.

Credits

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].