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 | * constructor(haptic: Haptic){
|
16 | * haptic.selection();
|
17 | * }
|
18 | * }
|
19 | *
|
20 | * ```
|
21 | */
|
22 | var Haptic = (function () {
|
23 | /**
|
24 | * @param {?} plt
|
25 | */
|
26 | function Haptic(plt) {
|
27 | var _this = this;
|
28 | if (plt) {
|
29 | plt.ready().then(function () {
|
30 | _this._p = plt.win().TapticEngine;
|
31 | });
|
32 | }
|
33 | }
|
34 | /**
|
35 | * Check to see if the Haptic Plugin is available
|
36 | *
|
37 | * @return {?}
|
38 | */
|
39 | Haptic.prototype.available = function () {
|
40 | return !!this._p;
|
41 | };
|
42 | /**
|
43 | * Trigger a selection changed haptic event. Good for one-time events
|
44 | * (not for gestures)
|
45 | * @return {?}
|
46 | */
|
47 | Haptic.prototype.selection = function () {
|
48 | this._p && this._p.selection();
|
49 | };
|
50 | /**
|
51 | * Tell the haptic engine that a gesture for a selection change is starting.
|
52 | * @return {?}
|
53 | */
|
54 | Haptic.prototype.gestureSelectionStart = function () {
|
55 | this._p && this._p.gestureSelectionStart();
|
56 | };
|
57 | /**
|
58 | * Tell the haptic engine that a selection changed during a gesture.
|
59 | * @return {?}
|
60 | */
|
61 | Haptic.prototype.gestureSelectionChanged = function () {
|
62 | this._p && this._p.gestureSelectionChanged();
|
63 | };
|
64 | /**
|
65 | * Tell the haptic engine we are done with a gesture. This needs to be
|
66 | * called lest resources are not properly recycled.
|
67 | * @return {?}
|
68 | */
|
69 | Haptic.prototype.gestureSelectionEnd = function () {
|
70 | this._p && this._p.gestureSelectionEnd();
|
71 | };
|
72 | /**
|
73 | * Use this to indicate success/failure/warning to the user.
|
74 | * options should be of the type `{ type: 'success' }` (or `warning`/`error`)
|
75 | * @param {?} options
|
76 | * @return {?}
|
77 | */
|
78 | Haptic.prototype.notification = function (options) {
|
79 | this._p && this._p.notification(options);
|
80 | };
|
81 | /**
|
82 | * Use this to indicate success/failure/warning to the user.
|
83 | * options should be of the type `{ style: 'light' }` (or `medium`/`heavy`)
|
84 | * @param {?} options
|
85 | * @return {?}
|
86 | */
|
87 | Haptic.prototype.impact = function (options) {
|
88 | this._p && this._p.impact(options);
|
89 | };
|
90 | return Haptic;
|
91 | }());
|
92 | export { Haptic };
|
93 | Haptic.decorators = [
|
94 | { type: Injectable },
|
95 | ];
|
96 | /**
|
97 | * @nocollapse
|
98 | */
|
99 | Haptic.ctorParameters = function () { return [
|
100 | { type: Platform, },
|
101 | ]; };
|
102 | function Haptic_tsickle_Closure_declarations() {
|
103 | /** @type {?} */
|
104 | Haptic.decorators;
|
105 | /**
|
106 | * @nocollapse
|
107 | * @type {?}
|
108 | */
|
109 | Haptic.ctorParameters;
|
110 | /** @type {?} */
|
111 | Haptic.prototype._p;
|
112 | }
|
113 | //# sourceMappingURL=haptic.js.map |
\ | No newline at end of file |