@mulsense/xnew 0.4.2 → 0.4.3

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.
@@ -5,7 +5,7 @@
5
5
  })(this, (function (xnew, RAPIER) { 'use strict';
6
6
 
7
7
  var xrapier2d = {
8
- initialize({ gravity = { x: 0.0, y: 9.81 } } = {}) {
8
+ initialize({ gravity = { x: 0.0, y: -9.81 } } = {}) {
9
9
  xnew.extend(Root, { gravity });
10
10
  },
11
11
  get world() {
@@ -2,7 +2,7 @@ import xnew from '@mulsense/xnew';
2
2
  import RAPIER from '@dimforge/rapier2d-compat';
3
3
 
4
4
  var xrapier2d = {
5
- initialize({ gravity = { x: 0.0, y: 9.81 } } = {}) {
5
+ initialize({ gravity = { x: 0.0, y: -9.81 } } = {}) {
6
6
  xnew.extend(Root, { gravity });
7
7
  },
8
8
  get world() {
package/dist/xnew.d.ts CHANGED
@@ -22,19 +22,10 @@ declare class MapMap<Key1, Key2, Value> extends Map<Key1, Map<Key2, Value>> {
22
22
 
23
23
  type UnitElement = HTMLElement | SVGElement;
24
24
 
25
- interface EventProps {
26
- element: UnitElement;
27
- type: string;
28
- listener: Function;
29
- options?: boolean | AddEventListenerOptions;
30
- }
31
25
  declare class EventManager {
32
26
  private map;
33
- add(props: EventProps): void;
34
- remove({ type, listener }: {
35
- type: string;
36
- listener: Function;
37
- }): void;
27
+ add(element: UnitElement, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
28
+ remove(type: string, listener: Function): void;
38
29
  private basic;
39
30
  private resize;
40
31
  private click;
package/dist/xnew.js CHANGED
@@ -212,7 +212,8 @@
212
212
  constructor() {
213
213
  this.map = new MapMap();
214
214
  }
215
- add(props) {
215
+ add(element, type, listener, options) {
216
+ const props = { element, type, listener, options };
216
217
  let finalize;
217
218
  if (props.type === 'resize') {
218
219
  finalize = this.resize(props);
@@ -255,7 +256,7 @@
255
256
  }
256
257
  this.map.set(props.type, props.listener, finalize);
257
258
  }
258
- remove({ type, listener }) {
259
+ remove(type, listener) {
259
260
  const finalize = this.map.get(type, listener);
260
261
  if (finalize) {
261
262
  finalize();
@@ -458,9 +459,9 @@
458
459
  }
459
460
  isActive = false;
460
461
  };
461
- this.add({ element, options, type: 'dragstart', listener: dragstart });
462
- this.add({ element, options, type: 'dragmove', listener: dragmove });
463
- this.add({ element, options, type: 'dragend', listener: dragend });
462
+ this.add(element, 'dragstart', dragstart, options);
463
+ this.add(element, 'dragmove', dragmove, options);
464
+ this.add(element, 'dragend', dragend, options);
464
465
  function getOthers(id) {
465
466
  const backup = map.get(id);
466
467
  map.delete(id);
@@ -469,9 +470,9 @@
469
470
  return others;
470
471
  }
471
472
  return () => {
472
- this.remove({ type: 'dragstart', listener: dragstart });
473
- this.remove({ type: 'dragmove', listener: dragmove });
474
- this.remove({ type: 'dragend', listener: dragend });
473
+ this.remove('dragstart', dragstart);
474
+ this.remove('dragmove', dragmove);
475
+ this.remove('dragend', dragend);
475
476
  };
476
477
  }
477
478
  key(props) {
@@ -810,7 +811,7 @@
810
811
  unit._.listeners.set(type, listener, { element: unit.element, component: unit._.currentComponent, execute });
811
812
  Unit.type2units.add(type, unit);
812
813
  if (/^[A-Za-z]/.test(type)) {
813
- unit._.eventManager.add({ element: unit.element, type, listener: execute, options });
814
+ unit._.eventManager.add(unit.element, type, execute, options);
814
815
  }
815
816
  }
816
817
  }
@@ -824,7 +825,7 @@
824
825
  return;
825
826
  unit._.listeners.delete(type, listener);
826
827
  if (/^[A-Za-z]/.test(type)) {
827
- unit._.eventManager.remove({ type, listener: item.execute });
828
+ unit._.eventManager.remove(type, item.execute);
828
829
  }
829
830
  });
830
831
  if (unit._.listeners.has(type) === false) {
package/dist/xnew.mjs CHANGED
@@ -206,7 +206,8 @@ class EventManager {
206
206
  constructor() {
207
207
  this.map = new MapMap();
208
208
  }
209
- add(props) {
209
+ add(element, type, listener, options) {
210
+ const props = { element, type, listener, options };
210
211
  let finalize;
211
212
  if (props.type === 'resize') {
212
213
  finalize = this.resize(props);
@@ -249,7 +250,7 @@ class EventManager {
249
250
  }
250
251
  this.map.set(props.type, props.listener, finalize);
251
252
  }
252
- remove({ type, listener }) {
253
+ remove(type, listener) {
253
254
  const finalize = this.map.get(type, listener);
254
255
  if (finalize) {
255
256
  finalize();
@@ -452,9 +453,9 @@ class EventManager {
452
453
  }
453
454
  isActive = false;
454
455
  };
455
- this.add({ element, options, type: 'dragstart', listener: dragstart });
456
- this.add({ element, options, type: 'dragmove', listener: dragmove });
457
- this.add({ element, options, type: 'dragend', listener: dragend });
456
+ this.add(element, 'dragstart', dragstart, options);
457
+ this.add(element, 'dragmove', dragmove, options);
458
+ this.add(element, 'dragend', dragend, options);
458
459
  function getOthers(id) {
459
460
  const backup = map.get(id);
460
461
  map.delete(id);
@@ -463,9 +464,9 @@ class EventManager {
463
464
  return others;
464
465
  }
465
466
  return () => {
466
- this.remove({ type: 'dragstart', listener: dragstart });
467
- this.remove({ type: 'dragmove', listener: dragmove });
468
- this.remove({ type: 'dragend', listener: dragend });
467
+ this.remove('dragstart', dragstart);
468
+ this.remove('dragmove', dragmove);
469
+ this.remove('dragend', dragend);
469
470
  };
470
471
  }
471
472
  key(props) {
@@ -804,7 +805,7 @@ class Unit {
804
805
  unit._.listeners.set(type, listener, { element: unit.element, component: unit._.currentComponent, execute });
805
806
  Unit.type2units.add(type, unit);
806
807
  if (/^[A-Za-z]/.test(type)) {
807
- unit._.eventManager.add({ element: unit.element, type, listener: execute, options });
808
+ unit._.eventManager.add(unit.element, type, execute, options);
808
809
  }
809
810
  }
810
811
  }
@@ -818,7 +819,7 @@ class Unit {
818
819
  return;
819
820
  unit._.listeners.delete(type, listener);
820
821
  if (/^[A-Za-z]/.test(type)) {
821
- unit._.eventManager.remove({ type, listener: item.execute });
822
+ unit._.eventManager.remove(type, item.execute);
822
823
  }
823
824
  });
824
825
  if (unit._.listeners.has(type) === false) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "Component-Oriented Programming"
6
6
  ],
7
- "version": "0.4.2",
7
+ "version": "0.4.3",
8
8
  "main": "dist/xnew.js",
9
9
  "module": "dist/xnew.mjs",
10
10
  "types": "dist/xnew.d.ts",