ios-haptics 0.1.1 → 0.1.2
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 +6 -6
- package/dist/index.d.ts +5 -3
- package/dist/index.js +11 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ios-haptics
|
|
1
|
+
# 📳 ios-haptics
|
|
2
2
|
|
|
3
3
|
javascript library for haptic feedback inside of safari on ios
|
|
4
4
|
|
|
@@ -9,13 +9,13 @@ javascript library for haptic feedback inside of safari on ios
|
|
|
9
9
|
|
|
10
10
|
demo: [ios-haptics demo](https://codepen.io/tijnjh/pen/KwpgPqB)
|
|
11
11
|
|
|
12
|
-
## installation
|
|
12
|
+
## 📦 installation
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
15
|
npm i ios-haptics
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## usage
|
|
18
|
+
## 🚀 usage
|
|
19
19
|
|
|
20
20
|
```javascript
|
|
21
21
|
import { haptic } from 'ios-haptics'
|
|
@@ -30,7 +30,7 @@ haptic.confirm()
|
|
|
30
30
|
haptic.error()
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
## how it works
|
|
33
|
+
## ⚙️ how it works
|
|
34
34
|
|
|
35
35
|
this uses the `<input type="checkbox" switch />` (introduced in safari 17.4), which has haptic feedback when toggled
|
|
36
36
|
|
|
@@ -40,5 +40,5 @@ on devices that support it, `navigator.vibrate()` is called instead, so it works
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
improvements
|
|
43
|
+
feel free to send a pr or open an issue if you have suggestions or find
|
|
44
|
+
improvements
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/index.d.ts
|
|
2
|
-
|
|
2
|
+
interface haptic {
|
|
3
3
|
/** @deprecated */
|
|
4
4
|
apply: never;
|
|
5
5
|
/** @deprecated */
|
|
@@ -18,6 +18,8 @@ declare interface Haptic {
|
|
|
18
18
|
prototype: never;
|
|
19
19
|
/** @deprecated */
|
|
20
20
|
toString: never;
|
|
21
|
+
/** @deprecated */
|
|
22
|
+
Symbol: never;
|
|
21
23
|
/** a single haptic */
|
|
22
24
|
(): void;
|
|
23
25
|
/** two rapid haptics */
|
|
@@ -25,6 +27,6 @@ declare interface Haptic {
|
|
|
25
27
|
/** three rapid haptics */
|
|
26
28
|
error: () => void;
|
|
27
29
|
}
|
|
28
|
-
declare const
|
|
30
|
+
declare const __haptic: haptic;
|
|
29
31
|
//#endregion
|
|
30
|
-
export {
|
|
32
|
+
export { __haptic as haptic };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ios-haptics v0.1.
|
|
2
|
+
* ios-haptics v0.1.2
|
|
3
3
|
* tijn.dev
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
function
|
|
7
|
+
function _haptic() {
|
|
8
8
|
try {
|
|
9
9
|
if (navigator.vibrate) {
|
|
10
10
|
navigator.vibrate(50);
|
|
@@ -22,7 +22,7 @@ function haptic() {
|
|
|
22
22
|
document.head.removeChild(labelEl);
|
|
23
23
|
} catch {}
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
_haptic.confirm = () => {
|
|
26
26
|
if (navigator.vibrate) {
|
|
27
27
|
navigator.vibrate([
|
|
28
28
|
50,
|
|
@@ -31,10 +31,10 @@ haptic.confirm = () => {
|
|
|
31
31
|
]);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
setTimeout(() =>
|
|
34
|
+
_haptic();
|
|
35
|
+
setTimeout(() => _haptic(), 120);
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
_haptic.error = () => {
|
|
38
38
|
if (navigator.vibrate) {
|
|
39
39
|
navigator.vibrate([
|
|
40
40
|
50,
|
|
@@ -45,11 +45,11 @@ haptic.error = () => {
|
|
|
45
45
|
]);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
setTimeout(() =>
|
|
50
|
-
setTimeout(() =>
|
|
48
|
+
_haptic();
|
|
49
|
+
setTimeout(() => _haptic(), 120);
|
|
50
|
+
setTimeout(() => _haptic(), 240);
|
|
51
51
|
};
|
|
52
|
-
const
|
|
52
|
+
const __haptic = _haptic;
|
|
53
53
|
|
|
54
54
|
//#endregion
|
|
55
|
-
export {
|
|
55
|
+
export { __haptic as haptic };
|