@eva/plugin-renderer-event 1.2.7 → 1.2.8-fix.1
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/package.json +3 -3
- package/dist/miniprogram.js +0 -285
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-event",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8-fix.1",
|
|
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.
|
|
22
|
-
"@eva/eva.js": "1.2.
|
|
21
|
+
"@eva/plugin-renderer": "1.2.8-fix.1",
|
|
22
|
+
"@eva/eva.js": "1.2.8-fix.1",
|
|
23
23
|
"pixi.js": "^4.8.7"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/dist/miniprogram.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || 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
|
-
|
|
3
|
-
import { __extends, __values, __spread, __decorate } from 'tslib';
|
|
4
|
-
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
5
|
-
import { OBSERVER_TYPE, decorators, Component } from '@eva/eva.js/dist/miniprogram';
|
|
6
|
-
import { Circle, Ellipse, Polygon, Rectangle, RoundedRectangle } from '@eva/miniprogram-pixi';
|
|
7
|
-
var hitAreaFunc = {
|
|
8
|
-
Circle: Circle,
|
|
9
|
-
Ellipse: Ellipse,
|
|
10
|
-
Polygon: Polygon,
|
|
11
|
-
Rect: Rectangle,
|
|
12
|
-
RoundedRect: RoundedRectangle
|
|
13
|
-
};
|
|
14
|
-
var propertyForHitArea = {
|
|
15
|
-
Circle: ['x', 'y', 'radius'],
|
|
16
|
-
Ellipse: ['x', 'y', 'width', 'height'],
|
|
17
|
-
Rect: ['x', 'y', 'width', 'height'],
|
|
18
|
-
RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
|
|
19
|
-
Polygon: ['paths']
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var Event$2 = function (_super) {
|
|
23
|
-
__extends(Event, _super);
|
|
24
|
-
|
|
25
|
-
function Event() {
|
|
26
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
|
|
28
|
-
_this.name = 'Event';
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Event.prototype.init = function (_a) {
|
|
33
|
-
var _b = (_a === void 0 ? {} : _a).moveWhenInside,
|
|
34
|
-
moveWhenInside = _b === void 0 ? false : _b;
|
|
35
|
-
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
36
|
-
this.renderSystem.rendererManager.register(this);
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
this.renderSystem.application.renderer.plugins.interaction.moveWhenInside = moveWhenInside;
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error('Setting moveWhenInside error.', e);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
Event.prototype.componentChanged = function (changed) {
|
|
46
|
-
switch (changed.type) {
|
|
47
|
-
case OBSERVER_TYPE.ADD:
|
|
48
|
-
this.add(changed);
|
|
49
|
-
break;
|
|
50
|
-
|
|
51
|
-
case OBSERVER_TYPE.REMOVE:
|
|
52
|
-
this.remove(changed);
|
|
53
|
-
break;
|
|
54
|
-
|
|
55
|
-
case OBSERVER_TYPE.CHANGE:
|
|
56
|
-
this.change(changed);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
Event.prototype.add = function (changed) {
|
|
62
|
-
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
63
|
-
container.interactive = true;
|
|
64
|
-
container.interactiveChildren = true;
|
|
65
|
-
var component = changed.component;
|
|
66
|
-
|
|
67
|
-
if (component.hitArea) {
|
|
68
|
-
this.addHitArea(changed, container, component.hitArea);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
container.on('pointertap', function (e) {
|
|
72
|
-
component.emit('tap', {
|
|
73
|
-
stopPropagation: function stopPropagation() {
|
|
74
|
-
return e.stopPropagation();
|
|
75
|
-
},
|
|
76
|
-
data: {
|
|
77
|
-
pointerId: e.data.pointerId,
|
|
78
|
-
position: {
|
|
79
|
-
x: e.data.global.x,
|
|
80
|
-
y: e.data.global.y
|
|
81
|
-
},
|
|
82
|
-
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
83
|
-
},
|
|
84
|
-
gameObject: component.gameObject
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
container.on('pointerdown', function (e) {
|
|
88
|
-
component.emit('touchstart', {
|
|
89
|
-
stopPropagation: function stopPropagation() {
|
|
90
|
-
return e.stopPropagation();
|
|
91
|
-
},
|
|
92
|
-
data: {
|
|
93
|
-
pointerId: e.data.pointerId,
|
|
94
|
-
position: {
|
|
95
|
-
x: e.data.global.x,
|
|
96
|
-
y: e.data.global.y
|
|
97
|
-
},
|
|
98
|
-
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
99
|
-
},
|
|
100
|
-
gameObject: component.gameObject
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
container.on('pointermove', function (e) {
|
|
104
|
-
component.emit('touchmove', {
|
|
105
|
-
stopPropagation: function stopPropagation() {
|
|
106
|
-
return e.stopPropagation();
|
|
107
|
-
},
|
|
108
|
-
data: {
|
|
109
|
-
pointerId: e.data.pointerId,
|
|
110
|
-
position: {
|
|
111
|
-
x: e.data.global.x,
|
|
112
|
-
y: e.data.global.y
|
|
113
|
-
},
|
|
114
|
-
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
115
|
-
},
|
|
116
|
-
gameObject: component.gameObject
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
container.on('pointerup', function (e) {
|
|
120
|
-
component.emit('touchend', {
|
|
121
|
-
stopPropagation: function stopPropagation() {
|
|
122
|
-
return e.stopPropagation();
|
|
123
|
-
},
|
|
124
|
-
data: {
|
|
125
|
-
pointerId: e.data.pointerId,
|
|
126
|
-
position: {
|
|
127
|
-
x: e.data.global.x,
|
|
128
|
-
y: e.data.global.y
|
|
129
|
-
},
|
|
130
|
-
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
131
|
-
},
|
|
132
|
-
gameObject: component.gameObject
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
container.on('pointerupoutside', function (e) {
|
|
136
|
-
component.emit('touchendoutside', {
|
|
137
|
-
stopPropagation: function stopPropagation() {
|
|
138
|
-
return e.stopPropagation();
|
|
139
|
-
},
|
|
140
|
-
data: {
|
|
141
|
-
pointerId: e.data.pointerId,
|
|
142
|
-
position: {
|
|
143
|
-
x: e.data.global.x,
|
|
144
|
-
y: e.data.global.y
|
|
145
|
-
},
|
|
146
|
-
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
147
|
-
},
|
|
148
|
-
gameObject: component.gameObject
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
container.on('pointercancel', function (e) {
|
|
152
|
-
component.emit('touchcancel', {
|
|
153
|
-
stopPropagation: function stopPropagation() {
|
|
154
|
-
return e.stopPropagation();
|
|
155
|
-
},
|
|
156
|
-
data: {
|
|
157
|
-
pointerId: e.data.pointerId,
|
|
158
|
-
position: {
|
|
159
|
-
x: e.data.global.x,
|
|
160
|
-
y: e.data.global.y
|
|
161
|
-
},
|
|
162
|
-
localPosition: container.worldTransform.applyInverse(e.data.global)
|
|
163
|
-
},
|
|
164
|
-
gameObject: component.gameObject
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
Event.prototype.remove = function (changed) {
|
|
170
|
-
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
171
|
-
container.interactive = false;
|
|
172
|
-
container.off('tap');
|
|
173
|
-
container.off('pointerdown');
|
|
174
|
-
container.off('pointermove');
|
|
175
|
-
container.off('pointerup');
|
|
176
|
-
container.off('pointerupoutside');
|
|
177
|
-
container.off('pointercancel');
|
|
178
|
-
changed.component.removeAllListeners();
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
Event.prototype.change = function (changed) {
|
|
182
|
-
var container = this.containerManager.getContainer(changed.gameObject.id);
|
|
183
|
-
container.interactive = true;
|
|
184
|
-
var component = changed.component;
|
|
185
|
-
|
|
186
|
-
if (component.hitArea) {
|
|
187
|
-
this.addHitArea(changed, container, component.hitArea);
|
|
188
|
-
} else {
|
|
189
|
-
component.hitArea = null;
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
Event.prototype.addHitArea = function (changed, container, hitArea) {
|
|
194
|
-
var e_1, _a, _b;
|
|
195
|
-
|
|
196
|
-
var type = hitArea.type,
|
|
197
|
-
style = hitArea.style;
|
|
198
|
-
|
|
199
|
-
if (!hitAreaFunc[type]) {
|
|
200
|
-
console.error(changed.gameObject.name + "'s hitArea type is not defined");
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
var params = [];
|
|
205
|
-
|
|
206
|
-
try {
|
|
207
|
-
for (var _c = __values(propertyForHitArea[type]), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
208
|
-
var key = _d.value;
|
|
209
|
-
params.push(style[key]);
|
|
210
|
-
}
|
|
211
|
-
} catch (e_1_1) {
|
|
212
|
-
e_1 = {
|
|
213
|
-
error: e_1_1
|
|
214
|
-
};
|
|
215
|
-
} finally {
|
|
216
|
-
try {
|
|
217
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
218
|
-
} finally {
|
|
219
|
-
if (e_1) throw e_1.error;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
var hitAreaShape = new ((_b = hitAreaFunc[type]).bind.apply(_b, __spread([void 0], params)))();
|
|
224
|
-
container.hitArea = hitAreaShape;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
Event.systemName = 'Event';
|
|
228
|
-
Event = __decorate([decorators.componentObserver({
|
|
229
|
-
Event: [{
|
|
230
|
-
prop: ['hitArea'],
|
|
231
|
-
deep: true
|
|
232
|
-
}]
|
|
233
|
-
})], Event);
|
|
234
|
-
return Event;
|
|
235
|
-
}(Renderer);
|
|
236
|
-
|
|
237
|
-
var Event$3 = Event$2;
|
|
238
|
-
var HIT_AREA_TYPE;
|
|
239
|
-
|
|
240
|
-
(function (HIT_AREA_TYPE) {
|
|
241
|
-
HIT_AREA_TYPE["Circle"] = "Circle";
|
|
242
|
-
HIT_AREA_TYPE["Ellipse"] = "Ellipse";
|
|
243
|
-
HIT_AREA_TYPE["Polygon"] = "Polygon";
|
|
244
|
-
HIT_AREA_TYPE["Rect"] = "Rect";
|
|
245
|
-
HIT_AREA_TYPE["RoundedRect"] = "RoundedRect";
|
|
246
|
-
})(HIT_AREA_TYPE || (HIT_AREA_TYPE = {}));
|
|
247
|
-
|
|
248
|
-
var Event = function (_super) {
|
|
249
|
-
__extends(Event, _super);
|
|
250
|
-
|
|
251
|
-
function Event() {
|
|
252
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
253
|
-
|
|
254
|
-
_this.hitArea = undefined;
|
|
255
|
-
return _this;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
Event.prototype.init = function (params) {
|
|
259
|
-
params && _extends(this, params);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
Event.prototype.emit = function (en) {
|
|
263
|
-
var args = [];
|
|
264
|
-
|
|
265
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
266
|
-
args[_i - 1] = arguments[_i];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return _super.prototype.emit.apply(this, __spread([en], args));
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
Event.prototype.once = function (en, fn, context) {
|
|
273
|
-
return _super.prototype.once.call(this, en, fn, context);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
Event.prototype.on = function (en, fn, context) {
|
|
277
|
-
return _super.prototype.on.call(this, en, fn, context);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
Event.componentName = 'Event';
|
|
281
|
-
return Event;
|
|
282
|
-
}(Component);
|
|
283
|
-
|
|
284
|
-
var Event$1 = Event;
|
|
285
|
-
export { Event$1 as Event, Event$3 as EventSystem, HIT_AREA_TYPE };
|