ios-haptics 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  javascript library for haptic feedback inside of safari on ios
4
4
 
5
- please note this only works on ios 17.4 to 26.4, as apple patched it in ios 26.5
6
-
7
5
  ![GitHub last commit](https://img.shields.io/github/last-commit/tijnjh/ios-haptics)
8
6
  [![npm version](https://img.shields.io/npm/v/ios-haptics.svg)](https://npmjs.com/package/ios-haptics)
9
7
  ![NPM Downloads](https://img.shields.io/npm/dm/ios-haptics)
@@ -51,7 +49,9 @@ vue
51
49
 
52
50
  this uses the `<input type="checkbox" switch />` (introduced in safari 17.4), which has haptic feedback when toggled
53
51
 
54
- `hapticTrigger` renders one of those on top of your element, so when the user taps it, safari triggers the native haptic feedback
52
+ `hapticTrigger` renders a transparent `<label>` on top of your element, wired to a hidden switch. when the user taps the element, the label forwards the tap to the switch as a trusted click, and safari triggers the native haptic feedback
53
+
54
+ the switch itself never sits under the finger, so scroll gestures that start on the element still scroll the page
55
55
 
56
56
  ---
57
57
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * ios-haptics v3.0.0
2
+ * ios-haptics v3.1.1
3
3
  * tijn.dev
4
4
  * @license MIT
5
5
  **/
6
- function e(e){if(!e)return;let t=document.createElement(`input`);t.type=`checkbox`,t.setAttribute(`switch`,``),Object.assign(t.style,{position:`absolute`,top:0,left:0,width:`100%`,height:`100%`,margin:0,opacity:0,cursor:`pointer`,clipPath:`inset(0 round 999px)`,touchAction:`manipulation`}),t.style.setProperty(`-webkit-tap-highlight-color`,`transparent`),e.style.position=`relative`,e.insertAdjacentElement(`beforeend`,t)}export{e as hapticTrigger};
6
+ function e(){return typeof navigator>`u`?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function t(t){if(!t||typeof window>`u`||!e()||t.querySelector(`[data-haptic-trigger]`))return;let n=document.createElement(`input`);n.type=`checkbox`,n.setAttribute(`switch`,``),n.setAttribute(`data-haptic-trigger`,``),n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1,Object.assign(n.style,{position:`absolute`,inset:`0`,width:`100%`,height:`100%`,margin:`0`,opacity:`0`,clipPath:`inset(0 round 999px)`,touchAction:`pan-x pan-y`}),n.style.setProperty(`-webkit-tap-highlight-color`,`transparent`),getComputedStyle(t).position===`static`&&(t.style.position=`relative`);let r=0,i=!1;n.addEventListener(`pointerdown`,e=>{r=e.clientY,i=!1},{passive:!0}),n.addEventListener(`pointermove`,e=>{Math.abs(e.clientY-r)>10&&(i=!0,n.checked=!1)},{passive:!0}),n.addEventListener(`pointerup`,()=>{i&&(n.checked=!1),i=!1},{passive:!0}),n.addEventListener(`pointercancel`,()=>{i=!1,n.checked=!1},{passive:!0}),t.insertAdjacentElement(`beforeend`,n)}export{t as hapticTrigger};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ios-haptics",
3
3
  "type": "module",
4
- "version": "3.1.1",
4
+ "version": "3.2.0",
5
5
  "description": "haptic feedback for ios safari",
6
6
  "author": "tijnjh",
7
7
  "license": "MIT",