wgge 1.1.1 → 1.1.2

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.
Files changed (2) hide show
  1. package/core/Collection.js +7 -17
  2. package/package.json +1 -1
@@ -47,15 +47,11 @@ export default class Collection extends NodeWithEvents {
47
47
  }
48
48
 
49
49
  removeInternal(index, element) {
50
- if (index >= 0) {
51
- this.items.splice(index, 1);
52
- }
53
- if (element) {
54
- this.triggerEvent('remove', element);
55
- this.triggerEvent('change');
56
- return element;
57
- }
58
- return false;
50
+ if (index < 0 || !element) return false;
51
+ this.items.splice(index, 1);
52
+ this.triggerEvent('remove', element);
53
+ this.triggerEvent('change');
54
+ return element;
59
55
  }
60
56
 
61
57
  reset() {
@@ -85,18 +81,12 @@ export default class Collection extends NodeWithEvents {
85
81
 
86
82
  swap(childA, childB) {
87
83
  const indexA = this.items.indexOf(childA);
88
- if (indexA < 0) {
89
- return;
90
- }
91
- this.removeInternal(indexA, childA);
92
-
93
84
  const indexB = this.items.indexOf(childB);
94
- if (indexB < 0) {
95
- this.insert(childA, indexA);
85
+ if (indexA < 0 || indexB < 0) {
96
86
  return;
97
87
  }
88
+ this.removeInternal(indexA, childA);
98
89
  this.removeInternal(indexB, childB);
99
-
100
90
  this.insert(childA, indexB);
101
91
  this.insert(childB, indexA);
102
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgge",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Web GL Game Engine",
5
5
  "main": "index.js",
6
6
  "devDependencies": {