@capacitor/haptics 4.0.0-beta.0 → 4.0.0-nightly-f0c6414.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 +3 -3
- package/dist/docs.json +1 -1
- package/dist/esm/definitions.d.ts +0 -2
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/Haptics.swift +20 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -171,9 +171,9 @@ For example, call this when a user has lifted their finger from a control
|
|
|
171
171
|
|
|
172
172
|
#### VibrateOptions
|
|
173
173
|
|
|
174
|
-
| Prop | Type | Description
|
|
175
|
-
| -------------- | ------------------- |
|
|
176
|
-
| **`duration`** | <code>number</code> | Duration of the vibration in milliseconds.
|
|
174
|
+
| Prop | Type | Description | Default | Since |
|
|
175
|
+
| -------------- | ------------------- | ------------------------------------------ | ---------------- | ----- |
|
|
176
|
+
| **`duration`** | <code>number</code> | Duration of the vibration in milliseconds. | <code>300</code> | 1.0.0 |
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
### Enums
|
package/dist/docs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;OAIG;IACH,gCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAcD,MAAM,CAAN,IAAY,gBAqBX;AArBD,WAAY,gBAAgB;IAC1B;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EArBW,gBAAgB,KAAhB,gBAAgB,QAqB3B;
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2DA,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;;OAIG;IACH,8BAAe,CAAA;IAEf;;;;OAIG;IACH,gCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB;AAcD,MAAM,CAAN,IAAY,gBAqBX;AArBD,WAAY,gBAAgB;IAC1B;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,uCAAmB,CAAA;IAEnB;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EArBW,gBAAgB,KAAhB,gBAAgB,QAqB3B;AAwBD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC","sourcesContent":["export interface HapticsPlugin {\n /**\n * Trigger a haptics \"impact\" feedback\n *\n * @since 1.0.0\n */\n impact(options?: ImpactOptions): Promise<void>;\n\n /**\n * Trigger a haptics \"notification\" feedback\n *\n * @since 1.0.0\n */\n notification(options?: NotificationOptions): Promise<void>;\n\n /**\n * Vibrate the device\n *\n * @since 1.0.0\n */\n vibrate(options?: VibrateOptions): Promise<void>;\n\n /**\n * Trigger a selection started haptic hint\n *\n * @since 1.0.0\n */\n selectionStart(): Promise<void>;\n\n /**\n * Trigger a selection changed haptic hint. If a selection was\n * started already, this will cause the device to provide haptic\n * feedback\n *\n * @since 1.0.0\n */\n selectionChanged(): Promise<void>;\n\n /**\n * If selectionStart() was called, selectionEnd() ends the selection.\n * For example, call this when a user has lifted their finger from a control\n *\n * @since 1.0.0\n */\n selectionEnd(): Promise<void>;\n}\n\nexport interface ImpactOptions {\n /**\n * Impact Feedback Style\n *\n * The mass of the objects in the collision simulated by a [UIImpactFeedbackGenerator](https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle) object.\n *\n * @default ImpactStyle.Heavy\n * @since 1.0.0\n */\n style: ImpactStyle;\n}\n\nexport enum ImpactStyle {\n /**\n * A collision between large, heavy user interface elements\n *\n * @since 1.0.0\n */\n Heavy = 'HEAVY',\n\n /**\n * A collision between moderately sized user interface elements\n *\n * @since 1.0.0\n */\n Medium = 'MEDIUM',\n\n /**\n * A collision between small, light user interface elements\n *\n * @since 1.0.0\n */\n Light = 'LIGHT',\n}\n\nexport interface NotificationOptions {\n /**\n * Notification Feedback Type\n *\n * The type of notification feedback generated by a [UINotificationFeedbackGenerator](https://developer.apple.com/documentation/uikit/uinotificationfeedbacktype) object.\n *\n * @default NotificationType.SUCCESS\n * @since 1.0.0\n */\n type: NotificationType;\n}\n\nexport enum NotificationType {\n /**\n * A notification feedback type indicating that a task has completed successfully\n *\n * @since 1.0.0\n */\n Success = 'SUCCESS',\n\n /**\n * A notification feedback type indicating that a task has produced a warning\n *\n * @since 1.0.0\n */\n Warning = 'WARNING',\n\n /**\n * A notification feedback type indicating that a task has failed\n *\n * @since 1.0.0\n */\n Error = 'ERROR',\n}\n\nexport interface VibrateOptions {\n /**\n * Duration of the vibration in milliseconds.\n *\n * @default 300\n * @since 1.0.0\n */\n duration: number;\n}\n\n/**\n * @deprecated Use `ImpactOptions`.\n * @since 1.0.0\n */\nexport type HapticsImpactOptions = ImpactOptions;\n\n/**\n * @deprecated Use `NotificationOptions`.\n * @since 1.0.0\n */\nexport type HapticsNotificationOptions = NotificationOptions;\n\n/**\n * @deprecated Use `NotificationType`.\n * @since 1.0.0\n */\nexport const HapticsNotificationType = NotificationType;\n\n/**\n * @deprecated Use `ImpactStyle`.\n * @since 1.0.0\n */\nexport const HapticsImpactStyle = ImpactStyle;\n"]}
|
package/ios/Plugin/Haptics.swift
CHANGED
|
@@ -37,33 +37,29 @@ import CoreHaptics
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
@objc public func vibrate(_ duration: Double) {
|
|
40
|
-
if
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
self.vibrate()
|
|
50
|
-
}
|
|
40
|
+
if CHHapticEngine.capabilitiesForHardware().supportsHaptics {
|
|
41
|
+
do {
|
|
42
|
+
let engine = try CHHapticEngine()
|
|
43
|
+
try engine.start()
|
|
44
|
+
engine.resetHandler = { [] in
|
|
45
|
+
do {
|
|
46
|
+
try engine.start()
|
|
47
|
+
} catch {
|
|
48
|
+
self.vibrate()
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
}
|
|
51
|
+
let intensity = CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0)
|
|
52
|
+
let sharpness = CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0)
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
let continuousEvent = CHHapticEvent(eventType: .hapticContinuous,
|
|
55
|
+
parameters: [intensity, sharpness],
|
|
56
|
+
relativeTime: 0.0,
|
|
57
|
+
duration: duration)
|
|
58
|
+
let pattern = try CHHapticPattern(events: [continuousEvent], parameters: [])
|
|
59
|
+
let player = try engine.makePlayer(with: pattern)
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
vibrate()
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
61
|
+
try player.start(atTime: 0)
|
|
62
|
+
} catch {
|
|
67
63
|
vibrate()
|
|
68
64
|
}
|
|
69
65
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/haptics",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-nightly-f0c6414.0",
|
|
4
4
|
"description": "The Haptics API provides physical feedback to the user through touch or vibration.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "f0c64141855ef34ddd32cfb217d4de195b0ad095"
|
|
83
83
|
}
|