Socket
Socket
Sign inDemoInstall

rangetouch

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

3

changelog.md
# Changelog
## v1.0.5
- Fixed issue with variable naming
## v1.0.4

@@ -4,0 +7,0 @@ - Fixed bug introduced in v1.0.3 with selector for disabled elements

2

dist/rangetouch.js

@@ -1,1 +0,1 @@

!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=t(e,document):"function"==typeof define&&define.amd?define(null,function(){t(e,document)}):e.rangetouch=t(e,document)}("undefined"!=typeof window?window:this,function(e,t){"use strict";function n(){d(t.body,l.events.start,c),d(t.body,l.events.move,c),d(t.body,l.events.end,c)}function o(){var e=t.createElement("style");return e.appendChild(t.createTextNode("")),t.head.appendChild(e),e.sheet}function r(){return[l.selectors.range,":not(",l.selectors.disabled,")"].join("")}function a(e){return!(e instanceof HTMLElement)||(e.matches(l.selectors.disabled)||e.disabled)}function d(e,t,n){e.addEventListener(t,n,!1)}function i(e){var t=(""+e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}function u(e,t){if(t<1){var n=i(t);return parseFloat(e.toFixed(n))}return Math.round(e/t)*t}function s(e){var t,n=e.target,o=e.changedTouches[0],r=parseFloat(n.getAttribute("min"))||0,a=parseFloat(n.getAttribute("max"))||100,d=parseFloat(n.getAttribute("step"))||1,i=a-r,s=n.getBoundingClientRect(),c=100/s.width*(l.thumbWidth/2)/100;return t=100/s.width*(o.clientX-s.left),t<0?t=0:t>100&&(t=100),t<50?t-=(100-2*t)*c:t>50&&(t+=2*(t-50)*c),r+u(i*(t/100),d)}function c(e){l.enabled&&"range"===e.target.type&&!a(e.target)&&(e.preventDefault(),e.target.value=s(e),e(e.target,e.type===l.events.end?"change":"input"))}var l={enabled:!0,addCSS:!0,thumbWidth:15,selectors:{range:'[type="range"]',disabled:".rangetouch--disabled"},events:{start:"touchstart",move:"touchmove",end:"touchend"}};return function(){if("ontouchstart"in t.documentElement){if(l.addCSS){var e=t.styleSheets;(e.length?e[0]:o()).insertRule(r()+" { user-select: none; -webkit-user-select: none; touch-action: manipulation; }",0)}n()}}(),{set:function(e,t){l[e]=t}}});
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=t(e,document):"function"==typeof define&&define.amd?define(null,function(){t(e,document)}):e.rangetouch=t(e,document)}("undefined"!=typeof window?window:this,function(e,t){"use strict";function n(){u(t.body,f.events.start,l),u(t.body,f.events.move,l),u(t.body,f.events.end,l)}function o(){var e=t.createElement("style");return e.appendChild(t.createTextNode("")),t.head.appendChild(e),e.sheet}function a(n,o,a){if(n&&o){var r;"function"==typeof e.CustomEvent?r=e.CustomEvent:(r=function(e,n){n=n||{bubbles:!1,cancelable:!1,detail:void 0};var o=t.createEvent("CustomEvent");return o.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),o},r.prototype=e.Event.prototype);var i=new r(o,{bubbles:!0,detail:a});n.dispatchEvent(i)}}function r(){return[f.selectors.range,":not(",f.selectors.disabled,")"].join("")}function i(e){return!(e instanceof HTMLElement)||(e.matches(f.selectors.disabled)||e.disabled)}function u(e,t,n){e.addEventListener(t,n,!1)}function d(e){var t=(""+e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}function c(e,t){if(t<1){var n=d(t);return parseFloat(e.toFixed(n))}return Math.round(e/t)*t}function s(e){var t,n=e.target,o=e.changedTouches[0],a=parseFloat(n.getAttribute("min"))||0,r=parseFloat(n.getAttribute("max"))||100,i=parseFloat(n.getAttribute("step"))||1,u=r-a,d=n.getBoundingClientRect(),s=100/d.width*(f.thumbWidth/2)/100;return t=100/d.width*(o.clientX-d.left),t<0?t=0:t>100&&(t=100),t<50?t-=(100-2*t)*s:t>50&&(t+=2*(t-50)*s),a+c(u*(t/100),i)}function l(e){f.enabled&&"range"===e.target.type&&!i(e.target)&&(e.preventDefault(),e.target.value=s(e),a(e.target,e.type===f.events.end?"change":"input"))}var f={enabled:!0,addCSS:!0,thumbWidth:15,selectors:{range:'[type="range"]',disabled:".rangetouch--disabled"},events:{start:"touchstart",move:"touchmove",end:"touchend"}};return function(){if("ontouchstart"in t.documentElement){if(f.addCSS){var e=t.styleSheets;(e.length?e[0]:o()).insertRule(r()+" { user-select: none; -webkit-user-select: none; touch-action: manipulation; }",0)}n()}}(),{set:function(e,t){f[e]=t}}});
{
"name": "rangetouch",
"version": "1.0.4",
"version": "1.0.5",
"description": "A super tiny library to make input type='range' sliders work better on touch devices",

@@ -5,0 +5,0 @@ "homepage": "https://rangetouch.com",

@@ -17,30 +17,34 @@ # RangeTouch

## 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:
To use RangeTouch, you just need to add `rangetouch.js` (either from the `/dist` (minified) or `/src/js` (unminified) folders). Ideally before the closing `</body>` tag:
```html
<script src="/path/to/rangetouch.js"></script>
<script src="/path/to/rangetouch.js" async></script>
```
It will automatically bind to all `<input type="range">` elements, even newlt injected ones.
It will automatically bind to all `<input type="range">` elements, even newly injected ones as it uses event delegation.
### CDN
You can even load RangeTouch from our CDN if you'd like:
You can load RangeTouch from our CDN (backed by the awesome [Fastly](https://www.fastly.com/)) if you'd like:
```html
<script src="https://cdn.rangetouch.com/1.0.4/rangetouch.js"></script>
<script src="https://cdn.rangetouch.com/1.0.5/rangetouch.js"></script>
```
### Node Package Manager (NPM)
### Node / NPM
[![npm version](https://badge.fury.io/js/rangetouch.svg)](https://badge.fury.io/js/rangetouch)
Using NPM, you can grab RangeTouch:
```
```bash
npm install rangetouch
```
[https://www.npmjs.com/package/rangetouch](https://www.npmjs.com/package/rangetouch)
### Bower
[![Bower version](https://badge.fury.io/bo/rangetouch.svg)](https://badge.fury.io/bo/rangetouch)
If bower is your thang, you can grab RangeTouch using:
```
```bash
bower install rangetouch
```
[http://bower.io/search/?q=rangetouch](http://bower.io/search/?q=rangetouch)

@@ -47,0 +51,0 @@

// ==========================================================================
// rangetouch.js v1.0.4
// rangetouch.js v1.0.5
// Making <input type="range"> work on touch devices

@@ -77,3 +77,3 @@ // https://github.com/selz/rangetouch

// Trigger event
function event(element, type, properties) {
function trigger(element, type, properties) {
// Bail if no element

@@ -208,3 +208,3 @@ if (!element || !type) {

// Trigger input event
event(event.target, (event.type === settings.events.end ? 'change' : 'input'));
trigger(event.target, (event.type === settings.events.end ? 'change' : 'input'));
}

@@ -211,0 +211,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc