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 - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

4

changelog.md
# Changelog
## v1.0.4
- Fixed bug introduced in v1.0.3 with selector for disabled elements
- No long require the upfront check for elements on the page given we just listen to events
## v1.0.3

@@ -4,0 +8,0 @@ - Fixed error if no `<input type="range">` found

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(){i(t.body,l.events.start,c),i(t.body,l.events.move,c),i(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.classList.contains(l.selectors.disabled)}function i(e,t,n){e.addEventListener(t,n,!1)}function u(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 d(e,t){if(t<1){var n=u(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,i=parseFloat(n.getAttribute("step"))||1,u=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+d(u*(t/100),i)}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){var e=r();if(t.querySelectorAll(e).length){if(l.addCSS){var a=t.styleSheets;(a.length?a[0]:o()).insertRule(e+" { 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(){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}}});
{
"name": "rangetouch",
"version": "1.0.3",
"version": "1.0.4",
"description": "A super tiny library to make input type='range' sliders work better on touch devices",

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

@@ -26,3 +26,3 @@ # RangeTouch

```html
<script src="https://cdn.rangetouch.com/1.0.3/rangetouch.js"></script>
<script src="https://cdn.rangetouch.com/1.0.4/rangetouch.js"></script>
```

@@ -29,0 +29,0 @@

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

@@ -50,13 +50,2 @@ // https://github.com/selz/rangetouch

// Build selector
var selector = getSelector();
// Find all inputs
var inputs = document.querySelectorAll(selector);
// Bail if nothing to setup
if (!inputs.length) {
return;
}
// Add useful CSS

@@ -66,3 +55,3 @@ if (settings.addCSS) {

var stylesheet = stylesheets.length ? stylesheets[0] : createStyleSheet();
stylesheet.insertRule(selector + ' { user-select: none; -webkit-user-select: none; touch-action: manipulation; }', 0);
stylesheet.insertRule(getSelector() + ' { user-select: none; -webkit-user-select: none; touch-action: manipulation; }', 0);
}

@@ -134,6 +123,6 @@

if (element instanceof HTMLElement) {
return element.classList.contains(settings.selectors.disabled);
return element.matches(settings.selectors.disabled) || element.disabled;
}
return false;
return true;
}

@@ -140,0 +129,0 @@

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