UNPKG

2.07 kBJavaScriptView Raw
1import { PointerEvents } from './pointer-events';
2/**
3 * @hidden
4 */
5var UIEventManager = (function () {
6 /**
7 * @param {?} plt
8 */
9 function UIEventManager(plt) {
10 this.plt = plt;
11 this.evts = [];
12 }
13 /**
14 * @param {?} config
15 * @return {?}
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 /** @type {?} */ eventListnerOpts = {
23 capture: config.capture,
24 passive: config.passive,
25 zone: config.zone
26 };
27 var /** @type {?} */ pointerEvents = new PointerEvents(this.plt, config.element, config.pointerDown, config.pointerMove, config.pointerUp, eventListnerOpts);
28 var /** @type {?} */ removeFunc = function () { return pointerEvents.destroy(); };
29 this.evts.push(removeFunc);
30 return pointerEvents;
31 };
32 /**
33 * @param {?} ele
34 * @param {?} eventName
35 * @param {?} callback
36 * @param {?} opts
37 * @return {?}
38 */
39 UIEventManager.prototype.listen = function (ele, eventName, callback, opts) {
40 if (ele) {
41 var /** @type {?} */ removeFunc = this.plt.registerListener(ele, eventName, callback, opts);
42 this.evts.push(removeFunc);
43 return removeFunc;
44 }
45 };
46 /**
47 * @return {?}
48 */
49 UIEventManager.prototype.unlistenAll = function () {
50 this.evts.forEach(function (unRegEvent) {
51 unRegEvent();
52 });
53 this.evts.length = 0;
54 };
55 /**
56 * @return {?}
57 */
58 UIEventManager.prototype.destroy = function () {
59 this.unlistenAll();
60 this.evts = null;
61 };
62 return UIEventManager;
63}());
64export { UIEventManager };
65function UIEventManager_tsickle_Closure_declarations() {
66 /** @type {?} */
67 UIEventManager.prototype.evts;
68 /** @type {?} */
69 UIEventManager.prototype.plt;
70}
71//# sourceMappingURL=ui-event-manager.js.map
\No newline at end of file