ios-haptics 0.1.4 → 0.1.5
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 +5 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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
|
+
|
|
5
7
|

|
|
6
8
|
[](https://npmjs.com/package/ios-haptics)
|
|
7
9
|

|
|
@@ -34,6 +36,9 @@ haptic.error()
|
|
|
34
36
|
|
|
35
37
|
this uses the `<input type="checkbox" switch />` (introduced in safari 17.4), which has haptic feedback when toggled
|
|
36
38
|
|
|
39
|
+
> [!IMPORTANT]
|
|
40
|
+
> apple patched the bug this library used for haptic feedback in ios 26.5. you can no longer trigger haptic feedback programmatically by calling `.click()` on a `<label>` that is `for` an `<input type="checkbox" switch />`. haptic feedback still works when the user directly clicks the checkbox switch themselves, but it can no longer be done programmatically.
|
|
41
|
+
|
|
37
42
|
every `haptic` call, it will create one of those in the background, toggle it, then remove it
|
|
38
43
|
|
|
39
44
|
on devices that support it, `navigator.vibrate()` is called instead, so it works on android too
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const supportsHaptics = typeof window === "undefined" ? false : window.matchMedia("(pointer: coarse)").matches;
|
|
7
|
+
const supportsHaptics = typeof window === "undefined" || typeof window.matchMedia !== "function" ? false : window.matchMedia("(pointer: coarse)").matches;
|
|
8
8
|
function _haptic() {
|
|
9
9
|
try {
|
|
10
10
|
if (navigator.vibrate) {
|