ios-haptics 0.0.9 → 0.1.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
@@ -3,11 +3,11 @@
3
3
  javascript library for haptic feedback inside of safari on ios
4
4
 
5
5
  ![GitHub last commit](https://img.shields.io/github/last-commit/tijnjh/ios-haptics)
6
- [![npm version](https://img.shields.io/npm/v/tsuite.svg)](https://npmjs.com/package/ios-haptics)
6
+ [![npm version](https://img.shields.io/npm/v/ios-haptics.svg)](https://npmjs.com/package/ios-haptics)
7
7
  ![NPM Downloads](https://img.shields.io/npm/dm/ios-haptics)
8
8
  ![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/ios-haptics)
9
9
 
10
- demo: [ios-haptics demo](https://wg.tijn.dev?h=s0kqLSnJz1PITLFVykgsKMlMVrKD0Db6ECk7Lkw1zvl5aZlFuTClCskQPj4trkVF%7EUVwDakgHlw5AA&c=UwAA&j=hYwxDsIwDEX3nMLKBAPJTsQC6sAxUJqSiDqObDMgxN1RlY6Vun3pv_cKNmKFL%7ERH0xLhBxMTgs2qTc7eJ0En2ReSUyfEBmNGim9MVd0z6TCnZV4_9_FgO2OPjmqcS3zBZQ2HPedGdSqMG6qL_dpNDMzEW4G0HMH8AQ)
10
+ demo: [ios-haptics demo](https://codepen.io/tijnjh/pen/KwpgPqB)
11
11
 
12
12
  ## installation
13
13
 
@@ -34,7 +34,7 @@ haptic.error()
34
34
 
35
35
  this uses the `<input type="checkbox" switch />` (introduced in safari 17.4), which has haptic feedback when toggled
36
36
 
37
- every `haptic` call, it will create one of those in the background, toggle it (which has haptic feedback), then remove it
37
+ every `haptic` call, it will create one of those in the background, toggle it, then remove it
38
38
 
39
39
  ---
40
40
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * ios-haptics v0.0.9
3
+ * ios-haptics v0.1.0
4
4
  * tijn.dev
5
5
  * @license MIT
6
6
  */
@@ -8,6 +8,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.haptic = haptic;
9
9
  function haptic() {
10
10
  try {
11
+ if (navigator.vibrate) {
12
+ navigator.vibrate(50);
13
+ return;
14
+ }
11
15
  const labelEl = document.createElement('label');
12
16
  labelEl.ariaHidden = 'true';
13
17
  labelEl.style.display = 'none';
@@ -25,10 +29,18 @@ function haptic() {
25
29
  }
26
30
  ;
27
31
  haptic.confirm = () => {
32
+ if (navigator.vibrate) {
33
+ navigator.vibrate([50, 70, 50]);
34
+ return;
35
+ }
28
36
  haptic();
29
37
  setTimeout(() => haptic(), 120);
30
38
  };
31
39
  haptic.error = () => {
40
+ if (navigator.vibrate) {
41
+ navigator.vibrate([50, 70, 50, 70, 50]);
42
+ return;
43
+ }
32
44
  haptic();
33
45
  setTimeout(() => haptic(), 120);
34
46
  setTimeout(() => haptic(), 240);
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ios-haptics v0.0.9
2
+ * ios-haptics v0.1.0
3
3
  * tijn.dev
4
4
  * @license MIT
5
5
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ios-haptics v0.0.9
2
+ * ios-haptics v0.1.0
3
3
  * tijn.dev
4
4
  * @license MIT
5
5
  */
package/dist/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  /**
2
- * ios-haptics v0.0.9
2
+ * ios-haptics v0.1.0
3
3
  * tijn.dev
4
4
  * @license MIT
5
5
  */
6
6
  function haptic() {
7
7
  try {
8
+ if (navigator.vibrate) {
9
+ navigator.vibrate(50);
10
+ return;
11
+ }
8
12
  const labelEl = document.createElement('label');
9
13
  labelEl.ariaHidden = 'true';
10
14
  labelEl.style.display = 'none';
@@ -22,10 +26,18 @@ function haptic() {
22
26
  }
23
27
  ;
24
28
  haptic.confirm = () => {
29
+ if (navigator.vibrate) {
30
+ navigator.vibrate([50, 70, 50]);
31
+ return;
32
+ }
25
33
  haptic();
26
34
  setTimeout(() => haptic(), 120);
27
35
  };
28
36
  haptic.error = () => {
37
+ if (navigator.vibrate) {
38
+ navigator.vibrate([50, 70, 50, 70, 50]);
39
+ return;
40
+ }
29
41
  haptic();
30
42
  setTimeout(() => haptic(), 120);
31
43
  setTimeout(() => haptic(), 240);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ios-haptics",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.1.0",
5
5
  "description": "haptic feedback for ios safari",
6
6
  "author": "tijnjh",
7
7
  "license": "MIT",
@@ -29,10 +29,10 @@
29
29
  "dist"
30
30
  ],
31
31
  "devDependencies": {
32
- "@antfu/eslint-config": "^4.16.2",
33
- "eslint": "^9.31.0",
34
- "typescript": "^5.8.3",
35
- "zshy": "^0.2.3"
32
+ "@antfu/eslint-config": "^5.1.0",
33
+ "eslint": "^9.32.0",
34
+ "typescript": "^5.9.2",
35
+ "zshy": "^0.3.4"
36
36
  },
37
37
  "zshy": "./src/index.ts"
38
38
  }