@starley/ion-directives 1.2.3 → 1.2.4
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
|
@@ -59,7 +59,9 @@ Resultado --> 123.456.789-00
|
|
|
59
59
|
|
|
60
60
|
### Para usar a pressHold 'appPressHold'
|
|
61
61
|
|
|
62
|
-
O tempo minimo e de 450 milisegundos!
|
|
62
|
+
O tempo minimo e de 450 milisegundos!
|
|
63
|
+
|
|
64
|
+
Caso queria alterar o tempo minimo basta adicionar o tempo desejado
|
|
63
65
|
|
|
64
66
|
Adicione a chamada de 'appPressHold' juntamente com o '(press)' pois ele será o responsavel pela ação!
|
|
65
67
|
|
|
@@ -71,6 +73,12 @@ my-component.html
|
|
|
71
73
|
<ion-label>PressHold</ion-label>
|
|
72
74
|
</ion-item>
|
|
73
75
|
...
|
|
76
|
+
|
|
77
|
+
... Caso queria usar com tempo definido
|
|
78
|
+
<ion-item appPressHold="250" (press)="doSomething()>
|
|
79
|
+
<ion-label>PressHold</ion-label>
|
|
80
|
+
</ion-item>
|
|
81
|
+
...
|
|
74
82
|
</ion-content>
|
|
75
83
|
```
|
|
76
84
|
|
|
@@ -20,13 +20,13 @@ export declare class TapDirective implements OnInit {
|
|
|
20
20
|
enabled: boolean;
|
|
21
21
|
interval: number;
|
|
22
22
|
};
|
|
23
|
-
constructor(
|
|
23
|
+
constructor();
|
|
24
24
|
ngOnInit(): void;
|
|
25
25
|
handleTaps(e: {
|
|
26
26
|
timeStamp: number;
|
|
27
27
|
}): void;
|
|
28
28
|
private emitTaps;
|
|
29
29
|
private resetTaps;
|
|
30
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<TapDirective,
|
|
30
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TapDirective, never>;
|
|
31
31
|
static ɵdir: i0.ɵɵDirectiveDeclaration<TapDirective, "[appTap]", never, {}, { "tap": "tap"; "doubleTap": "doubleTap"; }, never, never, false, never>;
|
|
32
32
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
/**
|
|
4
4
|
* Gerencia tap e doubleTap
|
|
5
5
|
* @author Starley Cazorla
|
|
6
6
|
*/
|
|
7
7
|
var TapDirective = /** @class */ (function () {
|
|
8
|
-
function TapDirective(
|
|
9
|
-
if (pattern === void 0) { pattern = 350; }
|
|
8
|
+
function TapDirective() {
|
|
10
9
|
this.tap = new EventEmitter();
|
|
11
10
|
this.doubleTap = new EventEmitter();
|
|
12
11
|
this.lastTap = 0;
|
|
@@ -22,8 +21,6 @@ var TapDirective = /** @class */ (function () {
|
|
|
22
21
|
enabled: false,
|
|
23
22
|
interval: 300,
|
|
24
23
|
};
|
|
25
|
-
this.tapGesture.interval = pattern;
|
|
26
|
-
this.doubleTapGesture.interval = pattern;
|
|
27
24
|
}
|
|
28
25
|
TapDirective.prototype.ngOnInit = function () {
|
|
29
26
|
this.tapGesture.enabled = true;
|
|
@@ -60,7 +57,7 @@ var TapDirective = /** @class */ (function () {
|
|
|
60
57
|
this.tapTimeout = null;
|
|
61
58
|
this.lastTap = 0;
|
|
62
59
|
};
|
|
63
|
-
TapDirective.ɵfac = function TapDirective_Factory(t) { return new (t || TapDirective)(
|
|
60
|
+
TapDirective.ɵfac = function TapDirective_Factory(t) { return new (t || TapDirective)(); };
|
|
64
61
|
TapDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TapDirective, selectors: [["", "appTap", ""]], hostBindings: function TapDirective_HostBindings(rf, ctx) { if (rf & 1) {
|
|
65
62
|
i0.ɵɵlistener("click", function TapDirective_click_HostBindingHandler($event) { return ctx.handleTaps($event); });
|
|
66
63
|
} }, outputs: { tap: "tap", doubleTap: "doubleTap" } });
|
|
@@ -72,10 +69,7 @@ export { TapDirective };
|
|
|
72
69
|
args: [{
|
|
73
70
|
selector: '[appTap]'
|
|
74
71
|
}]
|
|
75
|
-
}], function () { return [
|
|
76
|
-
type: Attribute,
|
|
77
|
-
args: ['appTap']
|
|
78
|
-
}] }]; }, { tap: [{
|
|
72
|
+
}], function () { return []; }, { tap: [{
|
|
79
73
|
type: Output
|
|
80
74
|
}], doubleTap: [{
|
|
81
75
|
type: Output
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tap.directive.js","sourceRoot":"","sources":["../../src/tap/tap.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"tap.directive.js","sourceRoot":"","sources":["../../src/tap/tap.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAU,MAAM,EAAE,MAAM,eAAe,CAAC;;AAEtF;;;GAGG;AAEH;IAqBI;QAhBU,QAAG,GAAG,IAAI,YAAY,EAAE,CAAC;QACzB,cAAS,GAAG,IAAI,YAAY,EAAE,CAAC;QACzC,YAAO,GAAG,CAAC,CAAC;QACZ,aAAQ,GAAG,CAAC,CAAC;QACb,eAAU,GAAQ,IAAI,CAAC;QACvB,eAAU,GAAG;YACT,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,GAAG;SAChB,CAAC;QACF,qBAAgB,GAAG;YACf,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,GAAG;SAChB,CAAC;IAEc,CAAC;IAEjB,+BAAQ,GAAR;QACI,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;IACzC,CAAC;IAGD,iCAAU,GADV,UACW,CAAyB;QADpC,iBAcC;QAZG,IAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAM,WAAW,GAAG,I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A5DD,IA4DC;SAzDY,YAAY;uFAAZ,YAAY;cAHxB,SAAS;eAAC;gBACP,QAAQ,EAAE,UAAU;aACvB;sCAGa,GAAG;kBAAZ,MAAM;YACG,SAAS;kBAAlB,MAAM;YAuBP,UAAU;kBADT,YAAY;mBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC","sourcesContent":["import { Directive, EventEmitter, HostListener, OnInit, Output } from '@angular/core';\n\n/**\n * Gerencia tap e doubleTap\n * @author Starley Cazorla\n */\n\n@Directive({\n selector: '[appTap]'\n})\nexport class TapDirective implements OnInit {\n\n @Output() tap = new EventEmitter();\n @Output() doubleTap = new EventEmitter();\n lastTap = 0;\n tapCount = 0;\n tapTimeout: any = null;\n tapGesture = {\n name: 'tap',\n enabled: false,\n interval: 250,\n };\n doubleTapGesture = {\n name: 'doubleTap',\n enabled: false,\n interval: 300,\n };\n\n constructor() { }\n\n ngOnInit(): void {\n this.tapGesture.enabled = true;\n this.doubleTapGesture.enabled = true;\n }\n\n @HostListener('click', ['$event'])\n handleTaps(e: { timeStamp: number; }) {\n const tapTimestamp = Math.floor(e.timeStamp);\n const isDoubleTap = this.lastTap + this.tapGesture.interval > tapTimestamp;\n if (!this.tapGesture.enabled && !this.doubleTapGesture.enabled) {\n return this.resetTaps();\n }\n this.tapCount++;\n if (isDoubleTap && this.doubleTapGesture.enabled) {\n this.emitTaps();\n } else if (!isDoubleTap) {\n this.tapTimeout = setTimeout(() => this.emitTaps(), this.tapGesture.interval);\n }\n this.lastTap = tapTimestamp;\n }\n\n private emitTaps() {\n if (this.tapCount === 1 && this.tapGesture.enabled) {\n this.tap.emit();\n } else if (this.tapCount === 2 && this.doubleTapGesture.enabled) {\n this.doubleTap.emit();\n }\n this.resetTaps();\n }\n\n private resetTaps() {\n clearTimeout(this.tapTimeout); // clear the old timeout\n this.tapCount = 0;\n this.tapTimeout = null;\n this.lastTap = 0;\n }\n\n}\n"]}
|