ios-haptics 0.0.7 → 0.0.8

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.
@@ -0,0 +1,11 @@
1
+ //#region src/index.d.ts
2
+ /**
3
+ * A single haptic "click"
4
+ */
5
+ declare const haptic: {
6
+ (): void;
7
+ confirm(): void;
8
+ error(): void;
9
+ };
10
+ //#endregion
11
+ export { haptic };
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * ios-haptics v0.0.8
3
+ * tijn.dev
4
+ * @license MIT
5
+ **/
6
+ //#region src/index.ts
7
+ /**
8
+ * A single haptic "click"
9
+ */
10
+ const haptic = () => {
11
+ try {
12
+ const label = document.createElement("label");
13
+ label.ariaHidden = "true";
14
+ label.style.display = "none";
15
+ const input = document.createElement("input");
16
+ input.type = "checkbox";
17
+ input.setAttribute("switch", "");
18
+ label.appendChild(input);
19
+ document.head.appendChild(label);
20
+ label.click();
21
+ document.head.removeChild(label);
22
+ } catch {}
23
+ };
24
+ /**
25
+ * Two rapid haptics (good for confirmation)
26
+ */
27
+ haptic.confirm = () => {
28
+ haptic();
29
+ setTimeout(() => haptic(), 120);
30
+ };
31
+ /**
32
+ * Three rapid haptics (useful for errors)
33
+ */
34
+ haptic.error = () => {
35
+ haptic();
36
+ setTimeout(() => haptic(), 120);
37
+ setTimeout(() => haptic(), 240);
38
+ };
39
+
40
+ //#endregion
41
+ export { haptic };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ios-haptics",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "haptic feedback for ios safari",
5
5
  "keywords": [
6
6
  "haptic",