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