neo.mjs 3.2.3 → 3.2.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.
@@ -28,15 +28,10 @@ class CountryGallery extends Gallery {
28
28
  */
29
29
  country_: null,
30
30
  /**
31
- * The image height of the gallery
32
- * @member {Number} imageHeight=240
31
+ * The item height of the gallery
32
+ * @member {Number} itemHeight=240
33
33
  */
34
- imageHeight: 280,
35
- /**
36
- * The image width of the gallery
37
- * @member {Number} imageWidth=320
38
- */
39
- imageWidth: 340,
34
+ itemHeight: 280,
40
35
  /**
41
36
  * @member {Object} itemTpl_
42
37
  */
@@ -74,6 +69,11 @@ class CountryGallery extends Gallery {
74
69
  ]}
75
70
  ]}
76
71
  ]},
72
+ /**
73
+ * The item width of the gallery
74
+ * @member {Number} itemWidth=320
75
+ */
76
+ itemWidth: 340,
77
77
  /**
78
78
  * The unique record field containing the id.
79
79
  * @member {String} keyProperty='id'
@@ -121,10 +121,10 @@ class CountryGallery extends Gallery {
121
121
 
122
122
  vdomItem.id = me.getItemVnodeId(record[me.keyProperty]);
123
123
 
124
- vdomItem.cn[0].style.height = me.imageHeight + 'px';
124
+ vdomItem.cn[0].style.height = me.itemHeight + 'px';
125
125
 
126
- firstChild.style.height = (me.imageHeight - 70) + 'px';
127
- firstChild.style.width = me.imageWidth + 'px';
126
+ firstChild.style.height = (me.itemHeight - 70) + 'px';
127
+ firstChild.style.width = me.itemWidth + 'px';
128
128
 
129
129
  firstChild.cn[0].cn[0].src = Util.getCountryFlagUrl(record.country);
130
130
  firstChild.cn[0].cn[1].html = record.country;
@@ -17,15 +17,15 @@ class Gallery extends BaseGallery {
17
17
  */
18
18
  cls: ['rw2-article-gallery', 'neo-gallery', 'page', 'view'],
19
19
  /**
20
- * The image height of the gallery
21
- * @member {Number} imageHeight=240
20
+ * The item height of the gallery
21
+ * @member {Number} itemHeight=240
22
22
  */
23
- imageHeight: 240,
23
+ itemHeight: 240,
24
24
  /**
25
- * The image width of the gallery
26
- * @member {Number} imageWidth=320
25
+ * The item width of the gallery
26
+ * @member {Number} itemWidth=320
27
27
  */
28
- imageWidth: 320,
28
+ itemWidth: 320,
29
29
  /**
30
30
  * Array containing the PreviewComponent references
31
31
  * @member {Array} items=[]
@@ -69,8 +69,8 @@ class Gallery extends BaseGallery {
69
69
  id : me.getItemVnodeId(record[me.keyProperty]),
70
70
  tabIndex: '-1',
71
71
  style: {
72
- height: me.imageHeight + 'px',
73
- width : me.imageWidth + 'px'
72
+ height: me.itemHeight + 'px',
73
+ width : me.itemWidth + 'px'
74
74
  },
75
75
  cn: [{
76
76
  cls: ['item-wrapper'],
@@ -28,15 +28,10 @@ class CountryGallery extends Gallery {
28
28
  */
29
29
  country_: null,
30
30
  /**
31
- * The image height of the gallery
32
- * @member {Number} imageHeight=240
31
+ * The item height of the gallery
32
+ * @member {Number} itemHeight=240
33
33
  */
34
- imageHeight: 280,
35
- /**
36
- * The image width of the gallery
37
- * @member {Number} imageWidth=320
38
- */
39
- imageWidth: 340,
34
+ itemHeight: 280,
40
35
  /**
41
36
  * @member {Object} itemTpl_
42
37
  */
@@ -94,6 +89,11 @@ class CountryGallery extends Gallery {
94
89
  }]
95
90
  }]
96
91
  },
92
+ /**
93
+ * The item width of the gallery
94
+ * @member {Number} itemWidth=320
95
+ */
96
+ itemWidth: 340,
97
97
  /**
98
98
  * The unique record field containing the id.
99
99
  * @member {String} keyProperty='id'
@@ -141,10 +141,10 @@ class CountryGallery extends Gallery {
141
141
 
142
142
  vdomItem.id = me.getItemVnodeId(record[me.keyProperty]);
143
143
 
144
- vdomItem.cn[0].style.height = me.imageHeight + 'px';
144
+ vdomItem.cn[0].style.height = me.itemHeight + 'px';
145
145
 
146
- firstChild.style.height = (me.imageHeight - 70) + 'px';
147
- firstChild.style.width = me.imageWidth + 'px';
146
+ firstChild.style.height = (me.itemHeight - 70) + 'px';
147
+ firstChild.style.width = me.itemWidth + 'px';
148
148
 
149
149
  firstChild.cn[0].cn[0].src = Util.getCountryFlagUrl(record.country);
150
150
  firstChild.cn[0].cn[1].html = record.country;
@@ -27,15 +27,10 @@ class CountryGallery extends Gallery {
27
27
  */
28
28
  cls: ['neo-country-gallery', 'neo-gallery', 'page', 'view'],
29
29
  /**
30
- * The image height of the gallery
31
- * @member {Number} imageHeight=240
30
+ * The item height of the gallery
31
+ * @member {Number} itemHeight=240
32
32
  */
33
- imageHeight: 280,
34
- /**
35
- * The image width of the gallery
36
- * @member {Number} imageWidth=320
37
- */
38
- imageWidth: 340,
33
+ itemHeight: 280,
39
34
  /**
40
35
  * @member {Object} itemTpl_
41
36
  */
@@ -73,6 +68,11 @@ class CountryGallery extends Gallery {
73
68
  ]}
74
69
  ]}
75
70
  ]},
71
+ /**
72
+ * The item width of the gallery
73
+ * @member {Number} itemWidth=320
74
+ */
75
+ itemWidth: 340,
76
76
  /**
77
77
  * The unique record field containing the id.
78
78
  * @member {String} keyProperty='id'
@@ -103,10 +103,10 @@ class CountryGallery extends Gallery {
103
103
 
104
104
  vdomItem.id = me.getItemVnodeId(record[me.keyProperty]);
105
105
 
106
- vdomItem.cn[0].style.height = me.imageHeight + 'px';
106
+ vdomItem.cn[0].style.height = me.itemHeight + 'px';
107
107
 
108
- firstChild.style.height = (me.imageHeight - 70) + 'px';
109
- firstChild.style.width = me.imageWidth + 'px';
108
+ firstChild.style.height = (me.itemHeight - 70) + 'px';
109
+ firstChild.style.width = me.itemWidth + 'px';
110
110
 
111
111
  firstChild.cn[0].cn[0].src = me.getCountryFlagUrl(record.country);
112
112
  firstChild.cn[0].cn[1].html = record.country;
@@ -184,7 +184,7 @@ class CountryGallery extends Gallery {
184
184
 
185
185
  imageName = map[imageName] || imageName;
186
186
 
187
- return 'https://raw.githubusercontent.com/neomjs/pages/master/resources/images/flaticon/country_flags/png/' + imageName + '.png'
187
+ return `https://raw.githubusercontent.com/neomjs/pages/master/resources/images/flaticon/country_flags/png/${imageName}.png`;
188
188
  }
189
189
 
190
190
  /**
@@ -1,4 +1,4 @@
1
- import Model from '../../../src/data/Model.mjs';
1
+ import Model from '../../../src/data/Model.mjs';
2
2
 
3
3
  /**
4
4
  * @class Neo.examples.component.coronaGallery.CountryModel
@@ -6,8 +6,14 @@ import Model from '../../../src/data/Model.mjs';
6
6
  */
7
7
  class CountryModel extends Model {
8
8
  static getConfig() {return {
9
+ /**
10
+ * @member {String} className='Neo.examples.component.coronaGallery.CountryModel'
11
+ * @protected
12
+ */
9
13
  className: 'Neo.examples.component.coronaGallery.CountryModel',
10
-
14
+ /**
15
+ * @member {Object[]} fields
16
+ */
11
17
  fields: [{
12
18
  name: 'cases',
13
19
  type: 'int'
@@ -7,9 +7,19 @@ import Store from '../../../src/data/Store.mjs';
7
7
  */
8
8
  class CountryStore extends Store {
9
9
  static getConfig() {return {
10
- className : 'Neo.examples.component.coronaGallery.CountryStore',
10
+ /**
11
+ * @member {String} className='Neo.examples.component.coronaGallery.CountryStore'
12
+ * @protected
13
+ */
14
+ className: 'Neo.examples.component.coronaGallery.CountryStore',
15
+ /**
16
+ * @member {String} keyProperty='country'
17
+ */
11
18
  keyProperty: 'country',
12
- model : CountryModel
19
+ /**
20
+ * @member {Neo.data.Model} model=CountryModel
21
+ */
22
+ model: CountryModel
13
23
  }}
14
24
  }
15
25
 
@@ -363,14 +363,11 @@ class MainContainer extends Viewport {
363
363
  }
364
364
  }
365
365
 
366
+ /**
367
+ * @param {Object[]} data
368
+ */
366
369
  addStoreItems(data) {
367
370
  this.getStore().data = data;
368
-
369
- setTimeout(() => {
370
- Neo.main.DomAccess.focus({
371
- id: this.gallery.id
372
- });
373
- }, 200);
374
371
  }
375
372
 
376
373
  /**
@@ -0,0 +1,38 @@
1
+ import Model from '../../../src/data/Model.mjs';
2
+
3
+ /**
4
+ * @class Neo.examples.component.gallery.ImageModel
5
+ * @extends Neo.data.Model
6
+ */
7
+ class ImageModel extends Model {
8
+ static getConfig() {return {
9
+ /**
10
+ * @member {String} className='Neo.examples.component.gallery.ImageModel'
11
+ * @protected
12
+ */
13
+ className: 'Neo.examples.component.gallery.ImageModel',
14
+ /**
15
+ * @member {Object[]} fields
16
+ */
17
+ fields: [{
18
+ name: 'firstname',
19
+ type: 'String'
20
+ }, {
21
+ name: 'id',
22
+ type: 'Integer'
23
+ }, {
24
+ name: 'image',
25
+ type: 'String'
26
+ }, {
27
+ name: 'isOnline',
28
+ type: 'Boolean'
29
+ }, {
30
+ name: 'lastname',
31
+ type: 'String'
32
+ }]
33
+ }}
34
+ }
35
+
36
+ Neo.applyClassConfig(ImageModel);
37
+
38
+ export default ImageModel;
@@ -0,0 +1,32 @@
1
+ import ImageModel from './ImageModel.mjs';
2
+ import Store from '../../../src/data/Store.mjs';
3
+
4
+ /**
5
+ * @class Neo.examples.component.gallery.ImageStore
6
+ * @extends Neo.data.Store
7
+ */
8
+ class ImageStore extends Store {
9
+ static getConfig() {return {
10
+ /**
11
+ * @member {String} className='Neo.examples.component.gallery.ImageModel'
12
+ * @protected
13
+ */
14
+ className: 'Neo.examples.component.gallery.ImageStore',
15
+ /**
16
+ * @member {Boolean} autoLoad=true
17
+ */
18
+ autoLoad: true,
19
+ /**
20
+ * @member {Neo.data.Model} model=ImageModel
21
+ */
22
+ model: ImageModel,
23
+ /**
24
+ * @member {String} url='../../resources/examples/data/ai_contacts.json'
25
+ */
26
+ url: '../../resources/examples/data/ai_contacts.json'
27
+ }}
28
+ }
29
+
30
+ Neo.applyClassConfig(ImageStore);
31
+
32
+ export default ImageStore;
@@ -1,4 +1,5 @@
1
1
  import Gallery from '../../../src/component/Gallery.mjs';
2
+ import ImageStore from './ImageStore.mjs';
2
3
  import NumberField from '../../../src/form/field/Number.mjs';
3
4
  import Panel from '../../../src/container/Panel.mjs';
4
5
  import RangeField from '../../../src/form/field/Range.mjs';
@@ -228,6 +229,7 @@ class MainContainer extends Viewport {
228
229
  me.gallery = Neo.create({
229
230
  module: Gallery,
230
231
  id : 'neo-gallery-1',
232
+ store : ImageStore,
231
233
  ...me.galleryConfig
232
234
  });
233
235
 
@@ -10,7 +10,7 @@ class MainStore extends Store {
10
10
  className: 'Neo.examples.list.animate.MainStore',
11
11
  autoLoad : true,
12
12
  model : MainModel,
13
- url : '../../resources/examples/data/circleContacts.json',
13
+ url : '../../resources/examples/data/circles/group1.json',
14
14
 
15
15
  filters: [{
16
16
  disabled : true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -49,8 +49,8 @@
49
49
  "neo-jsdoc": "^1.0.1",
50
50
  "neo-jsdoc-x": "^1.0.4",
51
51
  "postcss": "^8.4.6",
52
- "sass": "^1.49.7",
53
- "webpack": "^5.68.0",
52
+ "sass": "^1.49.8",
53
+ "webpack": "^5.69.1",
54
54
  "webpack-cli": "^4.9.2",
55
55
  "webpack-dev-server": "4.7.4",
56
56
  "webpack-hook-plugin": "^1.0.7",
@@ -16,6 +16,7 @@
16
16
 
17
17
  .neo-selected {
18
18
  .neo-item-wrapper {
19
+ opacity : .95;
19
20
  transform : translateZ(180px) scale(1.5);
20
21
  -webkit-box-reflect: unset!important;
21
22
  }
@@ -66,4 +67,4 @@
66
67
  .image-wrap.neo-selected img {
67
68
  transform: inherit;
68
69
  }
69
- }
70
+ }
@@ -62,6 +62,7 @@
62
62
 
63
63
  .neo-selected {
64
64
  .neo-item-wrapper {
65
+ opacity : .95;
65
66
  transform: translate3d(0, 0, 180px) scale(1.5);
66
67
  }
67
68
  }
@@ -69,4 +70,4 @@
69
70
  .image-wrap.neo-selected img {
70
71
  -webkit-box-reflect: unset !important;
71
72
  }
72
- }
73
+ }
@@ -42,6 +42,7 @@
42
42
 
43
43
  .neo-selected {
44
44
  .neo-item-wrapper {
45
+ opacity : .95;
45
46
  transform : translateZ(180px) scale(1.5);
46
47
  -webkit-box-reflect: unset!important;
47
48
  }
@@ -87,4 +88,4 @@
87
88
  .image-wrap.neo-selected img {
88
89
  transform: inherit;
89
90
  }
90
- }
91
+ }
@@ -41,7 +41,7 @@ class Circle extends Component {
41
41
  collapsed: true,
42
42
  /**
43
43
  * Additional used keys for the selection model
44
- * @member {Object} keys
44
+ * @member {Object} keys={}
45
45
  */
46
46
  keys: {},
47
47
  /**
@@ -73,21 +73,25 @@ class Circle extends Component {
73
73
  /**
74
74
  * @member {Number} rotateX_=0
75
75
  */
76
- rotateX_:0,
76
+ rotateX_: 0,
77
77
  /**
78
78
  * @member {Number} rotateY_=0
79
79
  */
80
- rotateY_:0,
80
+ rotateY_: 0,
81
81
  /**
82
82
  * @member {Number} rotateZ_=0
83
83
  */
84
- rotateZ_:0,
84
+ rotateZ_: 0,
85
85
  /**
86
- * @member {Neo.selection.Model} selectionModel_=null
86
+ * @member {Number} rotationIndex_=0
87
+ */
88
+ rotationIndex_: 0,
89
+ /**
90
+ * @member {Neo.selection.Model|null} selectionModel_=null
87
91
  */
88
92
  selectionModel_: null,
89
93
  /**
90
- * @member {Neo.collection.Base} store_=null
94
+ * @member {Neo.collection.Base|null} store_=null
91
95
  */
92
96
  store_: null,
93
97
  /**
@@ -283,6 +287,18 @@ class Circle extends Component {
283
287
  oldValue && this.rendered && this.rotate();
284
288
  }
285
289
 
290
+ /**
291
+ * Triggered after the rotationIndex config got changed
292
+ * @param {Number} value
293
+ * @param {Number} oldValue
294
+ * @protected
295
+ */
296
+ afterSetRotationIndex(value, oldValue) {
297
+ if (Neo.isNumber(oldValue)) {
298
+ console.log('afterSetRotationIndex', value);
299
+ }
300
+ }
301
+
286
302
  /**
287
303
  * Triggered after the selectionModel config got changed
288
304
  * @param {Neo.selection.Model} value
@@ -527,7 +543,7 @@ class Circle extends Component {
527
543
  * @returns {String|Number} itemId
528
544
  */
529
545
  getItemRecordId(vnodeId) {
530
- let itemId = vnodeId.split('__')[1],
546
+ let itemId = vnodeId.split('__').pop(),
531
547
  model = this.store.model,
532
548
  keyField = model?.getField(model.keyProperty);
533
549
 
@@ -602,18 +618,25 @@ class Circle extends Component {
602
618
  * @param {Object} data
603
619
  */
604
620
  onMouseWheel(data) {
605
- let me = this,
606
- deltaY = data.deltaY,
607
- rotateZ = me.rotateZ;
621
+ let me = this,
622
+ deltaY = data.deltaY,
623
+ itemAngle = 360 / me.maxItems,
624
+ maxAngle = Math.max(0, (me.store.getCount() - me.maxItems) * itemAngle),
625
+ rotateZ = me.rotateZ;
608
626
 
609
- if (deltaY > 1 || deltaY < -1) {rotateZ += deltaY;}
627
+ if (deltaY > 1 || deltaY < -1) {
628
+ rotateZ += deltaY;
629
+ }
610
630
 
611
631
  if (rotateZ < 0) {
612
632
  rotateZ = 0;
633
+ } else if (rotateZ > maxAngle) {
634
+ rotateZ = maxAngle;
613
635
  }
614
636
 
615
- if (!(me.rotateZ === 0 && rotateZ === 0)) {
616
- me.rotateZ = rotateZ;
637
+ if (!(me.rotateZ === 0 && rotateZ === 0) && !(me.rotateZ === maxAngle && rotateZ === maxAngle)) {
638
+ me.rotateZ = rotateZ;
639
+ me.rotationIndex = Math.floor(rotateZ / itemAngle);
617
640
 
618
641
  me.rotate();
619
642
  }
@@ -627,9 +650,9 @@ class Circle extends Component {
627
650
  vdom = me.vdom,
628
651
  circleCenterEl = vdom.cn[0],
629
652
  transform = [
630
- 'rotateX(' + me.rotateX + 'deg)',
631
- 'rotateY(' + me.rotateY + 'deg)',
632
- 'rotateZ(' + me.rotateZ + 'deg)'
653
+ `rotateX(${me.rotateX}deg)`,
654
+ `rotateY(${me.rotateY}deg)`,
655
+ `rotateZ(${me.rotateZ}deg)`
633
656
  ].join(' ');
634
657
 
635
658
  if (me.circleCenterHasTransitionCls) {
@@ -1,5 +1,4 @@
1
1
  import ClassSystemUtil from '../util/ClassSystem.mjs';
2
- import Collection from '../collection/Base.mjs'
3
2
  import Component from './Base.mjs';
4
3
  import GalleryModel from '../selection/GalleryModel.mjs';
5
4
  import NeoArray from '../util/Array.mjs';
@@ -38,20 +37,20 @@ class Gallery extends Component {
38
37
  */
39
38
  cls: ['neo-gallery', 'page', 'view'],
40
39
  /**
41
- * True disables selection of gallery items
40
+ * True disables selection of gallery items
42
41
  * @member {Boolean} disableSelection=false
43
42
  */
44
43
  disableSelection: false,
45
44
  /**
46
- * The image height of the gallery
47
- * @member {Number} imageHeight=160
45
+ * True will focus the gallery top level DOM node to enable the keyboard navigation right away
46
+ * @member {Boolean} focusOnMount=true
48
47
  */
49
- imageHeight: 160,
48
+ focusOnMount: true,
50
49
  /**
51
- * The image width of the gallery
52
- * @member {Number} imageWidth=120
50
+ * The image height of the gallery
51
+ * @member {Number} itemHeight=160
53
52
  */
54
- imageWidth: 120,
53
+ itemHeight: 160,
55
54
  /**
56
55
  * @member {Object} itemTpl_
57
56
  */
@@ -61,6 +60,11 @@ class Gallery extends Component {
61
60
  {tag: 'img', cls: [], style: {}}
62
61
  ]}
63
62
  ]},
63
+ /**
64
+ * The image width of the gallery
65
+ * @member {Number} itemWidth=120
66
+ */
67
+ itemWidth: 120,
64
68
  /**
65
69
  * The unique record field containing the id.
66
70
  * @member {String} keyProperty='id'
@@ -116,7 +120,7 @@ class Gallery extends Component {
116
120
  */
117
121
  selectedItemCls: 'neo-selected',
118
122
  /**
119
- * uses the selection.GalleryModel by default
123
+ * Uses the selection.GalleryModel by default
120
124
  * @member {Neo.selection.GalleryModel|null} selectionModel_=null
121
125
  */
122
126
  selectionModel_: null,
@@ -129,7 +133,7 @@ class Gallery extends Component {
129
133
  * The store instance or class containing the data for the gallery items
130
134
  * @member {Neo.data.Store|null} store_=null
131
135
  */
132
- store_: null, // todo: use a store once collecitons are integrated
136
+ store_: null,
133
137
  /**
134
138
  * The setTimeout() ids for calls which can get cancelled
135
139
  * @member {Array} transitionTimeouts=[]
@@ -173,23 +177,10 @@ class Gallery extends Component {
173
177
  super.construct(config);
174
178
 
175
179
  let me = this,
176
- domListeners = Neo.clone(me.domListeners, true),
177
- vdom = me.vdom,
178
- origin = vdom.cn[0],
179
- camera = origin.cn[0],
180
- dolly = camera.cn[0],
181
- view = dolly.cn[0],
182
- prefix = me.id + '__';
180
+ domListeners = Neo.clone(me.domListeners, true);
183
181
 
184
182
  me[itemsMounted] = false;
185
183
 
186
- camera.id = prefix + 'camera';
187
- dolly .id = prefix + 'dolly';
188
- origin.id = prefix + 'origin';
189
- view .id = prefix + 'view';
190
-
191
- me.vdom = vdom;
192
-
193
184
  domListeners.push({
194
185
  click: me.onClick,
195
186
  wheel: me.onMouseWheel,
@@ -213,6 +204,31 @@ class Gallery extends Component {
213
204
  }
214
205
  }
215
206
 
207
+ /**
208
+ * Triggered after the id config got changed
209
+ * @param {String} value
210
+ * @param {String} oldValue
211
+ * @protected
212
+ */
213
+ afterSetId(value, oldValue) {
214
+ super.afterSetId(value, oldValue);
215
+
216
+ let me = this,
217
+ vdom = me.vdom,
218
+ origin = vdom.cn[0],
219
+ camera = origin.cn[0],
220
+ dolly = camera.cn[0],
221
+ view = dolly.cn[0],
222
+ prefix = me.id + '__';
223
+
224
+ camera.id = prefix + 'camera';
225
+ dolly .id = prefix + 'dolly';
226
+ origin.id = prefix + 'origin';
227
+ view .id = prefix + 'view';
228
+
229
+ me.vdom = vdom;
230
+ }
231
+
216
232
  /**
217
233
  * Triggered after the maxItem config got changed
218
234
  * @param {Number} value
@@ -238,24 +254,24 @@ class Gallery extends Component {
238
254
  * @protected
239
255
  */
240
256
  afterSetMounted(value, oldValue) {
241
- let me = this;
257
+ let me = this,
258
+ selectionModel = me.selectionModel;
242
259
 
243
260
  if (value) {
261
+ me.focusOnMount && me.focus(me.id);
262
+
244
263
  setTimeout(() => {
245
264
  Neo.currentWorker.promiseMessage('main', {
246
265
  action : 'readDom',
247
266
  appName : me.appName,
248
- vnodeId : me.id,
249
- attributes: [
250
- 'offsetHeight',
251
- 'offsetWidth'
252
- ]
267
+ attributes: ['offsetHeight', 'offsetWidth'],
268
+ vnodeId : me.id
253
269
  }).then(data => {
254
270
  me.offsetHeight = data.attributes.offsetHeight;
255
271
  me.offsetWidth = data.attributes.offsetWidth;
256
272
 
257
- if (me.selectOnMount || me.selectionModel.hasSelection()) {
258
- let selection = me.selectionModel.getSelection(),
273
+ if (me.selectOnMount || selectionModel.hasSelection()) {
274
+ let selection = selectionModel.getSelection(),
259
275
  key = selection.length > 0 && selection[0];
260
276
 
261
277
  if (!key) {
@@ -264,12 +280,12 @@ class Gallery extends Component {
264
280
  key = me.store.getKeyAt(index);
265
281
  }
266
282
 
267
- me.selectionModel.select(key);
283
+ selectionModel.select(key);
268
284
  }
269
285
  });
270
286
  }, 300);
271
287
  } else {
272
- me.selectionModel.items = [];
288
+ selectionModel.items = [];
273
289
  }
274
290
  }
275
291
 
@@ -300,9 +316,7 @@ class Gallery extends Component {
300
316
  setTimeout(() => {
301
317
  let sm = me.selectionModel;
302
318
 
303
- if (sm.hasSelection()) {
304
- me.onSelectionChange(sm.items);
305
- }
319
+ sm.hasSelection() && me.onSelectionChange(sm.items);
306
320
  }, 500);
307
321
  }, 50);
308
322
  }
@@ -316,15 +330,13 @@ class Gallery extends Component {
316
330
  * @protected
317
331
  */
318
332
  afterSetSelectionModel(value, oldValue) {
319
- if (this.rendered) {
320
- value.register(this);
321
- oldValue?.destroy();
322
- }
333
+ oldValue?.destroy();
334
+ this.rendered && value.register(this);
323
335
  }
324
336
 
325
- afterSetTranslateX() {this.moveOrigin();}
326
- afterSetTranslateY() {this.moveOrigin();}
327
- afterSetTranslateZ() {this.moveOrigin();}
337
+ afterSetTranslateX() {this.moveOrigin()}
338
+ afterSetTranslateY() {this.moveOrigin()}
339
+ afterSetTranslateZ() {this.moveOrigin()}
328
340
 
329
341
  /**
330
342
  * Triggered before the store config gets changed.
@@ -336,24 +348,11 @@ class Gallery extends Component {
336
348
  beforeSetStore(value, oldValue) {
337
349
  let me = this;
338
350
 
339
- if (oldValue) {
340
- oldValue.destroy();
341
- }
342
-
343
- // todo: remove the if check once all demos use stores (instead of collections)
344
- if (value) {
345
- return ClassSystemUtil.beforeSetInstance(value, Store, {
346
- listeners : {
347
- load : me.onStoreLoad,
348
- sort : me.onSort,
349
- scope: me
350
- }
351
- });
352
- }
351
+ oldValue?.destroy();
353
352
 
354
- return Neo.create(Collection, {
355
- keyProperty: 'id',
353
+ return ClassSystemUtil.beforeSetInstance(value, Store, {
356
354
  listeners : {
355
+ load : me.onStoreLoad,
357
356
  sort : me.onSort,
358
357
  scope: me
359
358
  }
@@ -361,7 +360,7 @@ class Gallery extends Component {
361
360
  }
362
361
 
363
362
  /**
364
- * @returns {*}
363
+ * @returns {Object}
365
364
  */
366
365
  beforeGetItemTpl() {
367
366
  return Neo.clone(this._itemTpl, true);
@@ -399,8 +398,8 @@ class Gallery extends Component {
399
398
 
400
399
  imageVdom.src = Neo.config.resourcesPath + 'examples/' + record.image;
401
400
 
402
- imageVdom.style.height = me.imageHeight + 'px';
403
- imageVdom.style.width = me.imageWidth + 'px';
401
+ imageVdom.style.height = me.itemHeight + 'px';
402
+ imageVdom.style.width = me.itemWidth + 'px';
404
403
 
405
404
  return vdomItem;
406
405
  }
@@ -476,7 +475,7 @@ class Gallery extends Component {
476
475
  getCameraTransformForCell(index) {
477
476
  let me = this,
478
477
  amountRows = me.amountRows,
479
- imageWidth = me.imageWidth,
478
+ itemWidth = me.itemWidth,
480
479
  gap = 10,
481
480
  height = me.offsetHeight / (amountRows + 2),
482
481
  spacing = height + gap,
@@ -490,7 +489,7 @@ class Gallery extends Component {
490
489
  y = Math.floor(index / amountColumns);
491
490
  }
492
491
 
493
- let cx = x * (imageWidth + 10),
492
+ let cx = x * (itemWidth + 10),
494
493
  cy = (y + 0.5) * spacing * 1.1 + 50;
495
494
 
496
495
  return [-cx, -cy, 0];
@@ -532,8 +531,8 @@ class Gallery extends Component {
532
531
  }
533
532
 
534
533
  return this.translate3d(
535
- x * (me.imageWidth + 10),
536
- y * (me.imageHeight + 10) + 100,
534
+ x * (me.itemWidth + 10),
535
+ y * (me.itemHeight + 10) + 100,
537
536
  0
538
537
  );
539
538
  }
@@ -570,29 +569,7 @@ class Gallery extends Component {
570
569
  */
571
570
  onConstructed() {
572
571
  super.onConstructed();
573
-
574
- let me = this;
575
-
576
- me.selectionModel?.register(me);
577
-
578
- // load data for the example collection
579
- if (!(me.store instanceof Store)) {
580
- Neo.Xhr.promiseJson({
581
- insideNeo: true,
582
- url : '../../resources/examples/data/ai_contacts.json'
583
- }).then(data => {
584
- me.store.items = data.json.data;
585
- setTimeout(() => { // todo: rendering check
586
- me.createItems();
587
-
588
- if (me.selectOnMount) {
589
- me.afterSetMounted(true, false);
590
- }
591
- }, 100);
592
- }).catch(err => {
593
- console.log('Error for Neo.Xhr.request', err, me.id);
594
- });
595
- }
572
+ this.selectionModel?.register(this);
596
573
  }
597
574
 
598
575
  /**
@@ -622,13 +599,14 @@ class Gallery extends Component {
622
599
  onSelectionChange(value) {
623
600
  let me = this,
624
601
  index = me.store.indexOf(value?.[0] || 0),
625
- imageHeight = me.imageHeight,
626
- imageWidth = me.imageWidth,
602
+ itemHeight = me.itemHeight,
603
+ itemWidth = me.itemWidth,
627
604
  vdom = me.vdom,
628
605
  camera = vdom.cn[0].cn[0],
606
+ cameraStyle = camera.style,
629
607
  dollyTransform = me.getCameraTransformForCell(index),
630
608
  height = me.offsetHeight / (me.amountRows + 2),
631
- width = Math.round(height * imageWidth / imageHeight),
609
+ width = Math.round(height * itemWidth / itemHeight),
632
610
  spacing = width + 10,
633
611
  timeoutId;
634
612
 
@@ -642,7 +620,7 @@ class Gallery extends Component {
642
620
  action : 'updateDom',
643
621
  appName: me.appName,
644
622
  deltas : {
645
- id : me.id + '__' + 'dolly',
623
+ id : me.id + '__dolly',
646
624
  style: {
647
625
  transform: me.translate3d(...dollyTransform)
648
626
  }
@@ -654,7 +632,7 @@ class Gallery extends Component {
654
632
  vnodeId : me.id,
655
633
  functions: [{
656
634
  fn : 'getComputedStyle',
657
- params : [me.id + '__' + 'dolly', null],
635
+ params : [me.id + '__dolly', null],
658
636
  paramIsDomNode: [true, false],
659
637
  scope : 'defaultView',
660
638
  returnFnName : 'transform',
@@ -665,20 +643,20 @@ class Gallery extends Component {
665
643
  translateX, angle;
666
644
 
667
645
  if (transform.indexOf('matrix3d') === 0) {
668
- transform = transform.substring(9, transform.length - 1); // remove matrix3d( ... )
669
- transform = transform.split(',').map(e => parseFloat(e));
646
+ transform = transform.substring(9, transform.length - 1); // remove matrix3d( ... )
647
+ transform = transform.split(',').map(e => parseFloat(e));
670
648
  translateX = transform[12]; // bottom left element of the 4x4 matrix
671
649
  } else {
672
- transform = transform.substring(7, transform.length - 1); // remove matrix( ... )
673
- transform = transform.split(',').map(e => parseFloat(e));
650
+ transform = transform.substring(7, transform.length - 1); // remove matrix( ... )
651
+ transform = transform.split(',').map(e => parseFloat(e));
674
652
  translateX = transform[4]; // bottom left element of the 2x3 matrix
675
653
  }
676
654
 
677
655
  translateX = translateX - dollyTransform[0];
678
656
  angle = Math.min(Math.max(translateX / (spacing * 3), -1), 1) * 45;
679
657
 
680
- camera.style.transform = 'rotateY(' + angle + 'deg)';
681
- camera.style.transitionDuration = '330ms';
658
+ cameraStyle.transform = `rotateY(${angle}deg)`;
659
+ cameraStyle.transitionDuration = '330ms';
682
660
 
683
661
  me.vdom = vdom;
684
662
 
@@ -687,8 +665,8 @@ class Gallery extends Component {
687
665
 
688
666
  vdom = me.vdom;
689
667
 
690
- camera.style.transform = 'rotateY(0deg)';
691
- camera.style.transitionDuration = '5000ms';
668
+ cameraStyle.transform = 'rotateY(0deg)';
669
+ cameraStyle.transitionDuration = '5000ms';
692
670
 
693
671
  me.vdom = vdom;
694
672
  }, 330);
@@ -739,7 +717,7 @@ class Gallery extends Component {
739
717
  }
740
718
 
741
719
  /**
742
- * @param {Array} items
720
+ * @param {Object[]} items
743
721
  */
744
722
  onStoreLoad(items) {
745
723
  this.getItemsRoot().cn = []; // silent update
@@ -780,7 +758,7 @@ class Gallery extends Component {
780
758
  * @returns {String}
781
759
  */
782
760
  translate3d(x, y, z) {
783
- return 'translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)';
761
+ return `translate3d(${x}px, ${y}px, ${z}px)`;
784
762
  }
785
763
  }
786
764
 
package/src/list/Base.mjs CHANGED
@@ -233,7 +233,7 @@ class Base extends Component {
233
233
  * @protected
234
234
  */
235
235
  beforeSetSelectionModel(value, oldValue) {
236
- oldValue && oldValue.destroy();
236
+ oldValue?.destroy();
237
237
  return ClassSystemUtil.beforeSetInstance(value, ListModel);
238
238
  }
239
239
 
@@ -245,7 +245,7 @@ class Base extends Component {
245
245
  * @protected
246
246
  */
247
247
  beforeSetStore(value, oldValue) {
248
- oldValue && oldValue.destroy();
248
+ oldValue?.destroy();
249
249
  return ClassSystemUtil.beforeSetInstance(value, Store);
250
250
  }
251
251
 
@@ -41,15 +41,15 @@ class CircleModel extends Model {
41
41
  item = data.path[0],
42
42
  view = me.view,
43
43
  store = view.store,
44
- maxItems = Math.min(store.getCount(), view.maxItems - 1),
44
+ maxIndex = Math.min(store.getCount(), view.maxItems) - 1,
45
45
  index, itemId, recordId;
46
46
 
47
47
  if (item.cls.includes('neo-circle-item')) {
48
48
  recordId = parseInt(view.getItemRecordId(item.id));
49
49
  index = store.indexOf(recordId) + step;
50
50
 
51
- if (index < 0) {index = maxItems;}
52
- else if (index > maxItems) {index = 0;}
51
+ if (index < 0) {index = maxIndex;}
52
+ else if (index > maxIndex) {index = 0;}
53
53
  } else {
54
54
  index = 0;
55
55
  }
@@ -125,7 +125,7 @@ class ListModel extends Model {
125
125
  id = me.id,
126
126
  view = me.view;
127
127
 
128
- view.keys && view.keys._keys.push(
128
+ view.keys?._keys.push(
129
129
  {fn: 'onKeyDownDown' ,key: 'Down' ,scope: id},
130
130
  {fn: 'onKeyDownEnter' ,key: 'Enter' ,scope: id},
131
131
  {fn: 'onKeyDownLeft' ,key: 'Left' ,scope: id},
@@ -156,7 +156,7 @@ class ListModel extends Model {
156
156
  id = me.id,
157
157
  view = me.view;
158
158
 
159
- view.keys && view.keys.removeKeys([
159
+ view.keys?.removeKeys([
160
160
  {fn: 'onKeyDownDown' ,key: 'Down' ,scope: id},
161
161
  {fn: 'onKeyDownEnter' ,key: 'Enter' ,scope: id},
162
162
  {fn: 'onKeyDownLeft' ,key: 'Left' ,scope: id},