janusweb 1.5.48 → 1.5.49

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "janusweb",
3
3
  "description": "Web client for JanusVR worlds",
4
- "version": "1.5.48",
4
+ "version": "1.5.49",
5
5
  "main": "scripts/janusweb.js",
6
6
  "author": "James Baicoianu",
7
7
  "license": "MIT",
@@ -434,7 +434,7 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
434
434
  addForce: ['function', 'addForce'],
435
435
  removeForce: ['function', 'removeForce'],
436
436
  die: ['function', 'die'],
437
- refresh: [ 'function', 'refresh'],
437
+ refresh: ['function', 'refresh'],
438
438
  executeCallback: ['function', 'executeCallback'],
439
439
  isEqual: ['function', 'isEqual'],
440
440
  addClass: ['function', 'addClass'],
@@ -477,6 +477,8 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
477
477
  propertydefs[k] = {type: 'euler', default: v.clone() };
478
478
  } else if (typeof v == 'boolean') {
479
479
  propertydefs[k] = {type: 'boolean', default: v };
480
+ } else if (v instanceof CustomEvent) {
481
+ propertydefs[k] = {type: 'callback' };
480
482
  } else {
481
483
  propertydefs[k] = {type: 'object', default: v };
482
484
  }
@@ -147,6 +147,7 @@ document.body.dispatchEvent(click);
147
147
  this.currentavatar = '';
148
148
  this.getAvatarData().then(d => this.currentavatar = d);
149
149
  this.morphtargetchanges = {};
150
+ this.eventlistenerproxies = {};
150
151
  }
151
152
  this.createChildren = function() {
152
153
  elation.engine.things.janusplayer.extendclass.createChildren.call(this);
@@ -661,6 +662,9 @@ document.body.dispatchEvent(click);
661
662
  getSetting: ['function', 'getSetting'],
662
663
  setSetting: ['function', 'setSetting'],
663
664
  setAvatar: ['function', 'setAvatar'],
665
+ addEventListener: ['function', 'addEventListenerProxy'],
666
+ dispatchEvent: ['function', 'dispatchEvent'],
667
+ removeEventListener: ['function', 'removeEventListenerProxy'],
664
668
  });
665
669
  }
666
670
  return this._proxyobject;
@@ -1275,5 +1279,53 @@ document.body.dispatchEvent(click);
1275
1279
  }
1276
1280
  }
1277
1281
  }
1282
+ this.dispatchEvent = function(event, target) {
1283
+ if (!event.element) event.element = target || this;
1284
+ if (!event.target) {
1285
+ event.target = target || event.element;
1286
+ }
1287
+
1288
+ var handlerfn = 'on' + event.type;
1289
+ if (handlerfn in this) {
1290
+ this.executeCallback(this[handlerfn], event);
1291
+ }
1292
+
1293
+ // Bubble event up to parents, unless the event was thrown with bubbling disabled or an event handler called stopPropagation()
1294
+ let firedev = elation.events.fire(event);
1295
+ let returnValue = true;
1296
+ firedev.forEach(e => returnValue &= e.returnValue);
1297
+ if (event.bubbles !== false && returnValue && this.parent && this.parent.dispatchEvent) {
1298
+ event.element = this.parent;
1299
+ this.parent.dispatchEvent(event);
1300
+ }
1301
+ }
1302
+ this.addEventListenerProxy = function(name, handler, bubble) {
1303
+ var eventobj = {
1304
+ target: handler,
1305
+ fn: function(ev) {
1306
+ var proxyev = elation.events.clone(ev, {
1307
+ target: ev.target.getProxyObject(),
1308
+ });
1309
+ // Bind stopPropagation and preventDefault functions to the real event
1310
+ proxyev.stopPropagation = elation.bind(ev, ev.stopPropagation),
1311
+ proxyev.preventDefault = elation.bind(ev, ev.preventDefault),
1312
+ handler(proxyev);
1313
+ }
1314
+ };
1315
+ if (!this.eventlistenerproxies[name]) this.eventlistenerproxies[name] = [];
1316
+ this.eventlistenerproxies[name].push(eventobj);
1317
+
1318
+ elation.events.add(this, name, eventobj.fn, bubble);
1319
+ }
1320
+ this.removeEventListenerProxy = function(name, handler, bubble) {
1321
+ if (this.eventlistenerproxies[name]) {
1322
+ for (var i = 0; i < this.eventlistenerproxies[name].length; i++) {
1323
+ var evproxy = this.eventlistenerproxies[name][i];
1324
+ if (evproxy.target === handler) {
1325
+ elation.events.remove(this, name, evproxy.fn, bubble);
1326
+ }
1327
+ }
1328
+ }
1329
+ }
1278
1330
  }, elation.engine.things.player);
1279
1331
  });