项目作者: figuarnieri

项目描述 :
Input range with Dual Values
高级语言: HTML
项目地址: git://github.com/figuarnieri/dualrange.git
创建时间: 2018-02-22T21:31:20Z
项目社区:https://github.com/figuarnieri/dualrange

开源协议:

下载


DualRange.js

A javascript library, without dependencies like jQuery, Zepto and etc … Adds double values in an input range, with a callback to facilitate implementation of Min and Max values of the input, and with a minimum support for mobile

Install / Usage

Javascript

Add Dualrange javascript library

  1. <script src="https://cdn.rawgit.com/figuarnieri/dualrange/master/dualrange.min.js"></script> // CDN
  2. or
  3. <script src="path/js/dualrange.min.js"></script> // Relative path

CSS

Add Dualrange stylesheet

  1. <link rel="stylesheet" href="https://cdn.rawgit.com/figuarnieri/dualrange/master/dualrange.min.css" /> // CDN
  2. or
  3. <link rel="stylesheet" href="path/css/dualrange.min.css" /> // Relative path

Init / Callback

  1. new DualRange('.selector', (e) => {
  2. document.querySelector('.min').textContent = e.min;
  3. document.querySelector('.max').textContent = e.max;
  4. });

Request / Response

To retrieve input range values on the server, the concatenated name will be sent with a “[]”. So, if you write , the name RangeValues will be converted to RangeValues[]. This makes it easy for some languages to retrieve multiple values on the server

Examples

Simple

HTML

  1. <input type="range" name="Range" />

Min and Max

HTML

  1. <input type="range" name="Range" min="-10" max="175" />

Steps

HTML

  1. <input type="range" name="Range" step="10" />

Decimal Steps

HTML

  1. <input type="range" name="Range" step="0.01" />

Custom Style Class

HTML

  1. <input type="range" name="Range" class="custom-class" />

CSS

  1. .custom-class .dualrange__range {
  2. background-color: #09f;
  3. }
  4. .custom-class .dualrange__min, .custom-class .dualrange__max {
  5. border-radius: 6px;
  6. border-color: #09f;
  7. }
  8. .custom-class .dualrange__min:before, .custom-class .dualrange__max:before {
  9. background-color: #059;
  10. box-shadow: 0 0 4px #059;
  11. }
  12. .custom-class .dualrange__min:after, .custom-class .dualrange__max:after {
  13. border-color: #09f;
  14. }

Source

Github | @figuarnieri

License

The MIT License
Copyright 2018 © Filipe Guarnieri