1 | import { Injectable } from '@angular/core';
|
2 | import { Platform } from '../platform/platform';
|
3 | /**
|
4 | * @name Haptic
|
5 | * @description
|
6 | * The `Haptic` class interacts with a haptic engine on the device, if
|
7 | * available. Generally, Ionic components use this under the hood, but you're
|
8 | * welcome to get a bit crazy with it if you fancy.
|
9 | *
|
10 | * Currently, this uses the Taptic engine on iOS.
|
11 | *
|
12 | * @usage
|
13 | * ```ts
|
14 | * export class MyClass {
|
15 | *
|
16 | * constructor(haptic: Haptic) {
|
17 | * haptic.selection();
|
18 | * }
|
19 | * }
|
20 | *
|
21 | * ```
|
22 | */
|
23 | var Haptic = (function () {
|
24 | function Haptic(plt) {
|
25 | var _this = this;
|
26 | if (plt) {
|
27 | plt.ready().then(function () {
|
28 | _this._p = plt.win().TapticEngine;
|
29 | });
|
30 | }
|
31 | }
|
32 | /**
|
33 | * Check to see if the Haptic Plugin is available
|
34 | * @return {boolean} Returns true or false if the plugin is available
|
35 | *
|
36 | */
|
37 | Haptic.prototype.available = function () {
|
38 | return !!this._p;
|
39 | };
|
40 | /**
|
41 | * Trigger a selection changed haptic event. Good for one-time events
|
42 | * (not for gestures)
|
43 | */
|
44 | Haptic.prototype.selection = function () {
|
45 | this._p && this._p.selection();
|
46 | };
|
47 | /**
|
48 | * Tell the haptic engine that a gesture for a selection change is starting.
|
49 | */
|
50 | Haptic.prototype.gestureSelectionStart = function () {
|
51 | this._p && this._p.gestureSelectionStart();
|
52 | };
|
53 | /**
|
54 | * Tell the haptic engine that a selection changed during a gesture.
|
55 | */
|
56 | Haptic.prototype.gestureSelectionChanged = function () {
|
57 | this._p && this._p.gestureSelectionChanged();
|
58 | };
|
59 | /**
|
60 | * Tell the haptic engine we are done with a gesture. This needs to be
|
61 | * called lest resources are not properly recycled.
|
62 | */
|
63 | Haptic.prototype.gestureSelectionEnd = function () {
|
64 | this._p && this._p.gestureSelectionEnd();
|
65 | };
|
66 | /**
|
67 | * Use this to indicate success/failure/warning to the user.
|
68 | * options should be of the type `{ type: 'success' }` (or `warning`/`error`)
|
69 | */
|
70 | Haptic.prototype.notification = function (options) {
|
71 | this._p && this._p.notification(options);
|
72 | };
|
73 | /**
|
74 | * Use this to indicate success/failure/warning to the user.
|
75 | * options should be of the type `{ style: 'light' }` (or `medium`/`heavy`)
|
76 | */
|
77 | Haptic.prototype.impact = function (options) {
|
78 | this._p && this._p.impact(options);
|
79 | };
|
80 | Haptic.decorators = [
|
81 | { type: Injectable },
|
82 | ];
|
83 | /** @nocollapse */
|
84 | Haptic.ctorParameters = function () { return [
|
85 | { type: Platform, },
|
86 | ]; };
|
87 | return Haptic;
|
88 | }());
|
89 | export { Haptic };
|
90 | //# sourceMappingURL=haptic.js.map |
\ | No newline at end of file |