ios-haptics 0.0.3 → 0.0.4
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 +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -18
- package/package.json +22 -13
package/README.md
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
A small JavaScript utility for triggering subtle haptic feedback on iOS devices,
|
|
4
4
|
using a clever browser-specific quirk.
|
|
5
5
|
|
|
6
|
+
try it here: https://codepen.io/tijnjh/pen/KwpgPqB
|
|
7
|
+
|
|
6
8
|
## 🚀 Installation
|
|
7
9
|
|
|
8
10
|
```sh
|
|
9
|
-
npm
|
|
11
|
+
npm i ios-haptics
|
|
10
12
|
```
|
|
11
13
|
|
|
12
14
|
## 📦 Usage
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
//#region src/index.ts
|
|
2
2
|
const haptic = () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
try {
|
|
4
|
+
const label = document.createElement("label");
|
|
5
|
+
label.ariaHidden = "true";
|
|
6
|
+
label.style.display = "none";
|
|
7
|
+
const input = document.createElement("input");
|
|
8
|
+
input.type = "checkbox";
|
|
9
|
+
input.setAttribute("switch", "");
|
|
10
|
+
label.appendChild(input);
|
|
11
|
+
document.head.appendChild(label);
|
|
12
|
+
label.click();
|
|
13
|
+
document.head.removeChild(label);
|
|
14
|
+
} catch {}
|
|
15
15
|
};
|
|
16
16
|
haptic.confirm = () => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
haptic();
|
|
18
|
+
setTimeout(() => haptic(), 120);
|
|
19
19
|
};
|
|
20
20
|
haptic.error = () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
haptic();
|
|
22
|
+
setTimeout(() => haptic(), 120);
|
|
23
|
+
setTimeout(() => haptic(), 240);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
|
-
export { haptic };
|
|
27
|
+
export { haptic };
|
package/package.json
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ios-haptics",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "haptic feedback for ios safari",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"haptic",
|
|
7
|
+
"ios",
|
|
8
|
+
"feedback",
|
|
9
|
+
"haptic-feedback",
|
|
10
|
+
"taptic",
|
|
11
|
+
"safari",
|
|
12
|
+
"vibrate"
|
|
13
|
+
],
|
|
14
|
+
"repository": "tijnjh/ios-haptics",
|
|
15
|
+
"author": "tijnjh",
|
|
16
|
+
"type": "module",
|
|
10
17
|
"exports": {
|
|
11
18
|
".": "./dist/index.js",
|
|
12
19
|
"./package.json": "./package.json"
|
|
13
20
|
},
|
|
14
|
-
"
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
15
24
|
"files": [
|
|
16
25
|
"dist"
|
|
17
26
|
],
|
|
18
27
|
"scripts": {
|
|
19
|
-
"build": "tsdown"
|
|
20
|
-
"dev": "tsdown --watch"
|
|
28
|
+
"build": "tsdown"
|
|
21
29
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"tsdown": "latest",
|
|
32
|
+
"typescript": "^5.8.3"
|
|
33
|
+
}
|
|
25
34
|
}
|