@eva/plugin-renderer-event 1.2.7-editor.9 → 1.2.7-fix.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.
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
window.EVA = window.EVA || {};
|
|
4
3
|
window.EVA.plugin = window.EVA.plugin || {};
|
|
5
4
|
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
6
|
-
|
|
7
5
|
var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
8
6
|
'use strict';
|
|
9
7
|
|
|
@@ -17,34 +15,28 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
17
15
|
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
|
-
|
|
21
18
|
return _extendStatics(d, b);
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
function __extends(d, b) {
|
|
25
21
|
_extendStatics(d, b);
|
|
26
|
-
|
|
27
22
|
function __() {
|
|
28
23
|
this.constructor = d;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
function __decorate(decorators, target, key, desc) {
|
|
35
28
|
var c = arguments.length,
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
30
|
+
d;
|
|
38
31
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
|
|
39
32
|
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
40
33
|
}
|
|
41
34
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
42
35
|
}
|
|
43
|
-
|
|
44
36
|
function __values(o) {
|
|
45
37
|
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
m = s && o[s],
|
|
39
|
+
i = 0;
|
|
48
40
|
if (m) return m.call(o);
|
|
49
41
|
if (o && typeof o.length === "number") return {
|
|
50
42
|
next: function next() {
|
|
@@ -57,15 +49,13 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
57
49
|
};
|
|
58
50
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
function __read(o, n) {
|
|
62
53
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
63
54
|
if (!m) return o;
|
|
64
55
|
var i = m.call(o),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
r,
|
|
57
|
+
ar = [],
|
|
58
|
+
e;
|
|
69
59
|
try {
|
|
70
60
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
71
61
|
ar.push(r.value);
|
|
@@ -81,18 +71,14 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
81
71
|
if (e) throw e.error;
|
|
82
72
|
}
|
|
83
73
|
}
|
|
84
|
-
|
|
85
74
|
return ar;
|
|
86
75
|
}
|
|
87
|
-
|
|
88
76
|
function __spread() {
|
|
89
77
|
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
90
78
|
ar = ar.concat(__read(arguments[i]));
|
|
91
79
|
}
|
|
92
|
-
|
|
93
80
|
return ar;
|
|
94
81
|
}
|
|
95
|
-
|
|
96
82
|
var hitAreaFunc = {
|
|
97
83
|
Circle: pixi_js.Circle,
|
|
98
84
|
Ellipse: pixi_js.Ellipse,
|
|
@@ -107,56 +93,45 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
107
93
|
RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
|
|
108
94
|
Polygon: ['paths']
|
|
109
95
|
};
|
|
110
|
-
|
|
111
96
|
var Event$2 = function (_super) {
|
|
112
97
|
__extends(Event, _super);
|
|
113
|
-
|
|
114
98
|
function Event() {
|
|
115
99
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
116
|
-
|
|
117
100
|
_this.name = 'Event';
|
|
118
101
|
return _this;
|
|
119
102
|
}
|
|
120
|
-
|
|
121
103
|
Event.prototype.init = function (_a) {
|
|
122
104
|
var _b = (_a === void 0 ? {} : _a).moveWhenInside,
|
|
123
|
-
|
|
105
|
+
moveWhenInside = _b === void 0 ? false : _b;
|
|
124
106
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
125
107
|
this.renderSystem.rendererManager.register(this);
|
|
126
|
-
|
|
127
108
|
try {
|
|
128
109
|
this.renderSystem.application.renderer.plugins.interaction.moveWhenInside = moveWhenInside;
|
|
129
110
|
} catch (e) {
|
|
130
111
|
console.error('Setting moveWhenInside error.', e);
|
|
131
112
|
}
|
|
132
113
|
};
|
|
133
|
-
|
|
134
114
|
Event.prototype.componentChanged = function (changed) {
|
|
135
115
|
switch (changed.type) {
|
|
136
116
|
case eva_js.OBSERVER_TYPE.ADD:
|
|
137
117
|
this.add(changed);
|
|
138
118
|
break;
|
|
139
|
-
|
|
140
119
|
case eva_js.OBSERVER_TYPE.REMOVE:
|
|
141
120
|
this.remove(changed);
|
|
142
121
|
break;
|
|
143
|
-
|
|
144
122
|
case eva_js.OBSERVER_TYPE.CHANGE:
|
|
145
123
|
this.change(changed);
|
|
146
124
|
break;
|
|
147
125
|
}
|
|
148
126
|
};
|
|
149
|
-
|
|
150
127
|
Event.prototype.add = function (changed) {
|
|
151
128
|
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
152
129
|
container.interactive = true;
|
|
153
130
|
container.interactiveChildren = true;
|
|
154
131
|
var component = changed.component;
|
|
155
|
-
|
|
156
132
|
if (component.hitArea) {
|
|
157
133
|
this.addHitArea(changed, container, component.hitArea);
|
|
158
134
|
}
|
|
159
|
-
|
|
160
135
|
container.on('pointertap', function (e) {
|
|
161
136
|
component.emit('tap', {
|
|
162
137
|
stopPropagation: function stopPropagation() {
|
|
@@ -254,7 +229,6 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
254
229
|
});
|
|
255
230
|
});
|
|
256
231
|
};
|
|
257
|
-
|
|
258
232
|
Event.prototype.remove = function (changed) {
|
|
259
233
|
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
260
234
|
container.interactive = false;
|
|
@@ -266,32 +240,25 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
266
240
|
container.off('pointercancel');
|
|
267
241
|
changed.component.removeAllListeners();
|
|
268
242
|
};
|
|
269
|
-
|
|
270
243
|
Event.prototype.change = function (changed) {
|
|
271
244
|
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
272
245
|
container.interactive = true;
|
|
273
246
|
var component = changed.component;
|
|
274
|
-
|
|
275
247
|
if (component.hitArea) {
|
|
276
248
|
this.addHitArea(changed, container, component.hitArea);
|
|
277
249
|
} else {
|
|
278
250
|
component.hitArea = null;
|
|
279
251
|
}
|
|
280
252
|
};
|
|
281
|
-
|
|
282
253
|
Event.prototype.addHitArea = function (changed, container, hitArea) {
|
|
283
254
|
var e_1, _a, _b;
|
|
284
|
-
|
|
285
255
|
var type = hitArea.type,
|
|
286
|
-
|
|
287
|
-
|
|
256
|
+
style = hitArea.style;
|
|
288
257
|
if (!hitAreaFunc[type]) {
|
|
289
258
|
console.error(changed.gameObject.name + "'s hitArea type is not defined");
|
|
290
259
|
return;
|
|
291
260
|
}
|
|
292
|
-
|
|
293
261
|
var params = [];
|
|
294
|
-
|
|
295
262
|
try {
|
|
296
263
|
for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
297
264
|
var key = _d.value;
|
|
@@ -308,11 +275,9 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
308
275
|
if (e_1) throw e_1.error;
|
|
309
276
|
}
|
|
310
277
|
}
|
|
311
|
-
|
|
312
278
|
var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
|
|
313
279
|
container.hitArea = hitAreaShape;
|
|
314
280
|
};
|
|
315
|
-
|
|
316
281
|
Event.systemName = 'Event';
|
|
317
282
|
Event = __decorate([eva_js.decorators.componentObserver({
|
|
318
283
|
Event: [{
|
|
@@ -322,10 +287,8 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
322
287
|
})], Event);
|
|
323
288
|
return Event;
|
|
324
289
|
}(pluginRenderer.Renderer);
|
|
325
|
-
|
|
326
290
|
var Event$3 = Event$2;
|
|
327
291
|
exports.HIT_AREA_TYPE = void 0;
|
|
328
|
-
|
|
329
292
|
(function (HIT_AREA_TYPE) {
|
|
330
293
|
HIT_AREA_TYPE["Circle"] = "Circle";
|
|
331
294
|
HIT_AREA_TYPE["Ellipse"] = "Ellipse";
|
|
@@ -333,43 +296,32 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
333
296
|
HIT_AREA_TYPE["Rect"] = "Rect";
|
|
334
297
|
HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
|
|
335
298
|
})(exports.HIT_AREA_TYPE || (exports.HIT_AREA_TYPE = {}));
|
|
336
|
-
|
|
337
299
|
var Event = function (_super) {
|
|
338
300
|
__extends(Event, _super);
|
|
339
|
-
|
|
340
301
|
function Event() {
|
|
341
302
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
342
|
-
|
|
343
303
|
_this.hitArea = undefined;
|
|
344
304
|
return _this;
|
|
345
305
|
}
|
|
346
|
-
|
|
347
306
|
Event.prototype.init = function (params) {
|
|
348
307
|
params && _extends(this, params);
|
|
349
308
|
};
|
|
350
|
-
|
|
351
309
|
Event.prototype.emit = function (en) {
|
|
352
310
|
var args = [];
|
|
353
|
-
|
|
354
311
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
355
312
|
args[_i - 1] = arguments[_i];
|
|
356
313
|
}
|
|
357
|
-
|
|
358
314
|
return _super.prototype.emit.apply(this, __spread([en], args));
|
|
359
315
|
};
|
|
360
|
-
|
|
361
316
|
Event.prototype.once = function (en, fn, context) {
|
|
362
317
|
return _super.prototype.once.call(this, en, fn, context);
|
|
363
318
|
};
|
|
364
|
-
|
|
365
319
|
Event.prototype.on = function (en, fn, context) {
|
|
366
320
|
return _super.prototype.on.call(this, en, fn, context);
|
|
367
321
|
};
|
|
368
|
-
|
|
369
322
|
Event.componentName = 'Event';
|
|
370
323
|
return Event;
|
|
371
324
|
}(eva_js.Component);
|
|
372
|
-
|
|
373
325
|
var Event$1 = Event;
|
|
374
326
|
exports.Event = Event$1;
|
|
375
327
|
exports.EventSystem = Event$3;
|
|
@@ -378,5 +330,4 @@ var _EVA_IIFE_event = function (exports, pluginRenderer, eva_js, pixi_js) {
|
|
|
378
330
|
});
|
|
379
331
|
return exports;
|
|
380
332
|
}({}, EVA.plugin.renderer, EVA, PIXI);
|
|
381
|
-
|
|
382
333
|
window.EVA.plugin.renderer.event = window.EVA.plugin.renderer.event || _EVA_IIFE_event;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},_extends.apply(this,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_event=function(t,e,o,n){"use strict";var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},r(t,e)};function a(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function i(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var n,r,a=o.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return i}function p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}var l,c={Circle:n.Circle,Ellipse:n.Ellipse,Polygon:n.Polygon,Rect:n.Rectangle,RoundedRect:n.RoundedRectangle},d={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},s=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Event",e}return a(n,t),n.prototype.init=function(t){var o=(void 0===t?{}:t).moveWhenInside,n=void 0!==o&&o;this.renderSystem=this.game.getSystem(e.RendererSystem),this.renderSystem.rendererManager.register(this);try{this.renderSystem.application.renderer.plugins.interaction.moveWhenInside=n}catch(t){console.error("Setting moveWhenInside error.",t)}},n.prototype.componentChanged=function(t){switch(t.type){case o.OBSERVER_TYPE.ADD:this.add(t);break;case o.OBSERVER_TYPE.REMOVE:this.remove(t);break;case o.OBSERVER_TYPE.CHANGE:this.change(t)}},n.prototype.add=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0,e.interactiveChildren=!0;var o=t.component;o.hitArea&&this.addHitArea(t,e,o.hitArea),e.on("pointertap",(function(t){o.emit("tap",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerdown",(function(t){o.emit("touchstart",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointermove",(function(t){o.emit("touchmove",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerup",(function(t){o.emit("touchend",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointerupoutside",(function(t){o.emit("touchendoutside",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})})),e.on("pointercancel",(function(t){o.emit("touchcancel",{stopPropagation:function(){return t.stopPropagation()},data:{pointerId:t.data.pointerId,position:{x:t.data.global.x,y:t.data.global.y},localPosition:e.worldTransform.applyInverse(t.data.global)},gameObject:o.gameObject})}))},n.prototype.remove=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!1,e.off("tap"),e.off("pointerdown"),e.off("pointermove"),e.off("pointerup"),e.off("pointerupoutside"),e.off("pointercancel"),t.component.removeAllListeners()},n.prototype.change=function(t){var e=this.containerManager.getContainer(t.gameObject.id);e.interactive=!0;var o=t.component;o.hitArea?this.addHitArea(t,e,o.hitArea):o.hitArea=null},n.prototype.addHitArea=function(t,e,o){var n,r,a,i=o.type,l=o.style;if(c[i]){var s=[];try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,o=e&&t[e],n=0;if(o)return o.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(d[i]),f=u.next();!f.done;f=u.next()){var g=f.value;s.push(l[g])}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}var y=new((a=c[i]).bind.apply(a,p([void 0],s)));e.hitArea=y}else console.error(t.gameObject.name+"'s hitArea type is not defined")},n.systemName="Event",n=function(t,e,o,n){var r,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,o,n);else for(var p=t.length-1;p>=0;p--)(r=t[p])&&(i=(a<3?r(i):a>3?r(e,o,i):r(e,o))||i);return a>3&&i&&Object.defineProperty(e,o,i),i}([o.decorators.componentObserver({Event:[{prop:["hitArea"],deep:!0}]})],n),n}(e.Renderer),u=s;t.HIT_AREA_TYPE=void 0,(l=t.HIT_AREA_TYPE||(t.HIT_AREA_TYPE={})).Circle="Circle",l.Ellipse="Ellipse",l.Polygon="Polygon",l.Rect="Rect",l.RoundedRect="RoundedRect";var f=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hitArea=void 0,e}return a(e,t),e.prototype.init=function(t){t&&_extends(this,t)},e.prototype.emit=function(e){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return t.prototype.emit.apply(this,p([e],o))},e.prototype.once=function(e,o,n){return t.prototype.once.call(this,e,o,n)},e.prototype.on=function(e,o,n){return t.prototype.on.call(this,e,o,n)},e.componentName="Event",e}(o.Component),g=f;return t.Event=g,t.EventSystem=u,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA.plugin.renderer,EVA,PIXI);window.EVA.plugin.renderer.event=window.EVA.plugin.renderer.event||_EVA_IIFE_event;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import { __extends, __values, __spread, __decorate } from 'tslib';
|
|
3
|
+
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
4
|
+
import { OBSERVER_TYPE, decorators, Component } from '@eva/eva.js/dist/miniprogram';
|
|
5
|
+
import { Circle, Ellipse, Polygon, Rectangle, RoundedRectangle } from '@eva/miniprogram-pixi';
|
|
6
|
+
var hitAreaFunc = {
|
|
7
|
+
Circle: Circle,
|
|
8
|
+
Ellipse: Ellipse,
|
|
9
|
+
Polygon: Polygon,
|
|
10
|
+
Rect: Rectangle,
|
|
11
|
+
RoundedRect: RoundedRectangle
|
|
12
|
+
};
|
|
13
|
+
var propertyForHitArea = {
|
|
14
|
+
Circle: ['x', 'y', 'radius'],
|
|
15
|
+
Ellipse: ['x', 'y', 'width', 'height'],
|
|
16
|
+
Rect: ['x', 'y', 'width', 'height'],
|
|
17
|
+
RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
|
|
18
|
+
Polygon: ['paths']
|
|
19
|
+
};
|
|
20
|
+
var Event$2 = function (_super) {
|
|
21
|
+
__extends(Event, _super);
|
|
22
|
+
function Event() {
|
|
23
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
_this.name = 'Event';
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
Event.prototype.init = function (_a) {
|
|
28
|
+
var _b = (_a === void 0 ? {} : _a).moveWhenInside,
|
|
29
|
+
moveWhenInside = _b === void 0 ? false : _b;
|
|
30
|
+
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
31
|
+
this.renderSystem.rendererManager.register(this);
|
|
32
|
+
try {
|
|
33
|
+
this.renderSystem.application.renderer.plugins.interaction.moveWhenInside = moveWhenInside;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error('Setting moveWhenInside error.', e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Event.prototype.componentChanged = function (changed) {
|
|
39
|
+
switch (changed.type) {
|
|
40
|
+
case OBSERVER_TYPE.ADD:
|
|
41
|
+
this.add(changed);
|
|
42
|
+
break;
|
|
43
|
+
case OBSERVER_TYPE.REMOVE:
|
|
44
|
+
this.remove(changed);
|
|
45
|
+
break;
|
|
46
|
+
case OBSERVER_TYPE.CHANGE:
|
|
47
|
+
this.change(changed);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
Event.prototype.add = function (changed) {
|
|
52
|
+
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
53
|
+
container.interactive = true;
|
|
54
|
+
container.interactiveChildren = true;
|
|
55
|
+
var component = changed.component;
|
|
56
|
+
if (component.hitArea) {
|
|
57
|
+
this.addHitArea(changed, container, component.hitArea);
|
|
58
|
+
}
|
|
59
|
+
container.on('pointertap', function (e) {
|
|
60
|
+
component.emit('tap', {
|
|
61
|
+
stopPropagation: function stopPropagation() {
|
|
62
|
+
return e.stopPropagation();
|
|
63
|
+
},
|
|
64
|
+
data: {
|
|
65
|
+
pointerId: e.data.pointerId,
|
|
66
|
+
position: {
|
|
67
|
+
x: e.data.global.x,
|
|
68
|
+
y: e.data.global.y
|
|
69
|
+
},
|
|
70
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
71
|
+
},
|
|
72
|
+
gameObject: component.gameObject
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
container.on('pointerdown', function (e) {
|
|
76
|
+
component.emit('touchstart', {
|
|
77
|
+
stopPropagation: function stopPropagation() {
|
|
78
|
+
return e.stopPropagation();
|
|
79
|
+
},
|
|
80
|
+
data: {
|
|
81
|
+
pointerId: e.data.pointerId,
|
|
82
|
+
position: {
|
|
83
|
+
x: e.data.global.x,
|
|
84
|
+
y: e.data.global.y
|
|
85
|
+
},
|
|
86
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
87
|
+
},
|
|
88
|
+
gameObject: component.gameObject
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
container.on('pointermove', function (e) {
|
|
92
|
+
component.emit('touchmove', {
|
|
93
|
+
stopPropagation: function stopPropagation() {
|
|
94
|
+
return e.stopPropagation();
|
|
95
|
+
},
|
|
96
|
+
data: {
|
|
97
|
+
pointerId: e.data.pointerId,
|
|
98
|
+
position: {
|
|
99
|
+
x: e.data.global.x,
|
|
100
|
+
y: e.data.global.y
|
|
101
|
+
},
|
|
102
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
103
|
+
},
|
|
104
|
+
gameObject: component.gameObject
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
container.on('pointerup', function (e) {
|
|
108
|
+
component.emit('touchend', {
|
|
109
|
+
stopPropagation: function stopPropagation() {
|
|
110
|
+
return e.stopPropagation();
|
|
111
|
+
},
|
|
112
|
+
data: {
|
|
113
|
+
pointerId: e.data.pointerId,
|
|
114
|
+
position: {
|
|
115
|
+
x: e.data.global.x,
|
|
116
|
+
y: e.data.global.y
|
|
117
|
+
},
|
|
118
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
119
|
+
},
|
|
120
|
+
gameObject: component.gameObject
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
container.on('pointerupoutside', function (e) {
|
|
124
|
+
component.emit('touchendoutside', {
|
|
125
|
+
stopPropagation: function stopPropagation() {
|
|
126
|
+
return e.stopPropagation();
|
|
127
|
+
},
|
|
128
|
+
data: {
|
|
129
|
+
pointerId: e.data.pointerId,
|
|
130
|
+
position: {
|
|
131
|
+
x: e.data.global.x,
|
|
132
|
+
y: e.data.global.y
|
|
133
|
+
},
|
|
134
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
135
|
+
},
|
|
136
|
+
gameObject: component.gameObject
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
container.on('pointercancel', function (e) {
|
|
140
|
+
component.emit('touchcancel', {
|
|
141
|
+
stopPropagation: function stopPropagation() {
|
|
142
|
+
return e.stopPropagation();
|
|
143
|
+
},
|
|
144
|
+
data: {
|
|
145
|
+
pointerId: e.data.pointerId,
|
|
146
|
+
position: {
|
|
147
|
+
x: e.data.global.x,
|
|
148
|
+
y: e.data.global.y
|
|
149
|
+
},
|
|
150
|
+
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
151
|
+
},
|
|
152
|
+
gameObject: component.gameObject
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
Event.prototype.remove = function (changed) {
|
|
157
|
+
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
158
|
+
container.interactive = false;
|
|
159
|
+
container.off('tap');
|
|
160
|
+
container.off('pointerdown');
|
|
161
|
+
container.off('pointermove');
|
|
162
|
+
container.off('pointerup');
|
|
163
|
+
container.off('pointerupoutside');
|
|
164
|
+
container.off('pointercancel');
|
|
165
|
+
changed.component.removeAllListeners();
|
|
166
|
+
};
|
|
167
|
+
Event.prototype.change = function (changed) {
|
|
168
|
+
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
169
|
+
container.interactive = true;
|
|
170
|
+
var component = changed.component;
|
|
171
|
+
if (component.hitArea) {
|
|
172
|
+
this.addHitArea(changed, container, component.hitArea);
|
|
173
|
+
} else {
|
|
174
|
+
component.hitArea = null;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
Event.prototype.addHitArea = function (changed, container, hitArea) {
|
|
178
|
+
var e_1, _a, _b;
|
|
179
|
+
var type = hitArea.type,
|
|
180
|
+
style = hitArea.style;
|
|
181
|
+
if (!hitAreaFunc[type]) {
|
|
182
|
+
console.error(changed.gameObject.name + "'s hitArea type is not defined");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var params = [];
|
|
186
|
+
try {
|
|
187
|
+
for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
188
|
+
var key = _d.value;
|
|
189
|
+
params.push(style[key]);
|
|
190
|
+
}
|
|
191
|
+
} catch (e_1_1) {
|
|
192
|
+
e_1 = {
|
|
193
|
+
error: e_1_1
|
|
194
|
+
};
|
|
195
|
+
} finally {
|
|
196
|
+
try {
|
|
197
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
198
|
+
} finally {
|
|
199
|
+
if (e_1) throw e_1.error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
|
|
203
|
+
container.hitArea = hitAreaShape;
|
|
204
|
+
};
|
|
205
|
+
Event.systemName = 'Event';
|
|
206
|
+
Event = __decorate([decorators.componentObserver({
|
|
207
|
+
Event: [{
|
|
208
|
+
prop: ['hitArea'],
|
|
209
|
+
deep: true
|
|
210
|
+
}]
|
|
211
|
+
})], Event);
|
|
212
|
+
return Event;
|
|
213
|
+
}(Renderer);
|
|
214
|
+
var Event$3 = Event$2;
|
|
215
|
+
var HIT_AREA_TYPE;
|
|
216
|
+
(function (HIT_AREA_TYPE) {
|
|
217
|
+
HIT_AREA_TYPE["Circle"] = "Circle";
|
|
218
|
+
HIT_AREA_TYPE["Ellipse"] = "Ellipse";
|
|
219
|
+
HIT_AREA_TYPE["Polygon"] = "Polygon";
|
|
220
|
+
HIT_AREA_TYPE["Rect"] = "Rect";
|
|
221
|
+
HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
|
|
222
|
+
})(HIT_AREA_TYPE || (HIT_AREA_TYPE = {}));
|
|
223
|
+
var Event = function (_super) {
|
|
224
|
+
__extends(Event, _super);
|
|
225
|
+
function Event() {
|
|
226
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
227
|
+
_this.hitArea = undefined;
|
|
228
|
+
return _this;
|
|
229
|
+
}
|
|
230
|
+
Event.prototype.init = function (params) {
|
|
231
|
+
params && _extends(this, params);
|
|
232
|
+
};
|
|
233
|
+
Event.prototype.emit = function (en) {
|
|
234
|
+
var args = [];
|
|
235
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
236
|
+
args[_i - 1] = arguments[_i];
|
|
237
|
+
}
|
|
238
|
+
return _super.prototype.emit.apply(this, __spread([en], args));
|
|
239
|
+
};
|
|
240
|
+
Event.prototype.once = function (en, fn, context) {
|
|
241
|
+
return _super.prototype.once.call(this, en, fn, context);
|
|
242
|
+
};
|
|
243
|
+
Event.prototype.on = function (en, fn, context) {
|
|
244
|
+
return _super.prototype.on.call(this, en, fn, context);
|
|
245
|
+
};
|
|
246
|
+
Event.componentName = 'Event';
|
|
247
|
+
return Event;
|
|
248
|
+
}(Component);
|
|
249
|
+
var Event$1 = Event;
|
|
250
|
+
export { Event$1 as Event, Event$3 as EventSystem, HIT_AREA_TYPE };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-event",
|
|
3
|
-
"version": "1.2.7-
|
|
3
|
+
"version": "1.2.7-fix.4",
|
|
4
4
|
"description": "@eva/plugin-renderer-event",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-event.esm.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/plugin-renderer": "1.2.7-
|
|
22
|
-
"@eva/eva.js": "1.2.7-
|
|
21
|
+
"@eva/plugin-renderer": "1.2.7-fix.4",
|
|
22
|
+
"@eva/eva.js": "1.2.7-fix.4",
|
|
23
23
|
"pixi.js": "^4.8.7"
|
|
24
24
|
}
|
|
25
25
|
}
|