1 | import { PointerEvents } from './pointer-events';
|
2 |
|
3 |
|
4 |
|
5 | var UIEventManager = (function () {
|
6 | |
7 |
|
8 |
|
9 | function UIEventManager(plt) {
|
10 | this.plt = plt;
|
11 | this.evts = [];
|
12 | }
|
13 | |
14 |
|
15 |
|
16 |
|
17 | UIEventManager.prototype.pointerEvents = function (config) {
|
18 | if (!config.element || !config.pointerDown) {
|
19 | console.error('PointerEvents config is invalid');
|
20 | return;
|
21 | }
|
22 | var eventListnerOpts = {
|
23 | capture: config.capture,
|
24 | passive: config.passive,
|
25 | zone: config.zone
|
26 | };
|
27 | var pointerEvents = new PointerEvents(this.plt, config.element, config.pointerDown, config.pointerMove, config.pointerUp, eventListnerOpts);
|
28 | var removeFunc = function () { return pointerEvents.destroy(); };
|
29 | this.evts.push(removeFunc);
|
30 | return pointerEvents;
|
31 | };
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | UIEventManager.prototype.listen = function (ele, eventName, callback, opts) {
|
40 | if (ele) {
|
41 | var removeFunc = this.plt.registerListener(ele, eventName, callback, opts);
|
42 | this.evts.push(removeFunc);
|
43 | return removeFunc;
|
44 | }
|
45 | };
|
46 | |
47 |
|
48 |
|
49 | UIEventManager.prototype.unlistenAll = function () {
|
50 | this.evts.forEach(function (unRegEvent) {
|
51 | unRegEvent();
|
52 | });
|
53 | this.evts.length = 0;
|
54 | };
|
55 | |
56 |
|
57 |
|
58 | UIEventManager.prototype.destroy = function () {
|
59 | this.unlistenAll();
|
60 | this.evts = null;
|
61 | };
|
62 | return UIEventManager;
|
63 | }());
|
64 | export { UIEventManager };
|
65 | function UIEventManager_tsickle_Closure_declarations() {
|
66 |
|
67 | UIEventManager.prototype.evts;
|
68 |
|
69 | UIEventManager.prototype.plt;
|
70 | }
|
71 |
|
\ | No newline at end of file |