neo.mjs 3.2.3 → 3.2.6

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 (39) hide show
  1. package/apps/ServiceWorker.mjs +36 -0
  2. package/apps/covid/view/country/Gallery.mjs +11 -11
  3. package/apps/realworld2/view/article/Gallery.mjs +8 -8
  4. package/apps/sharedcovid/view/country/Gallery.mjs +11 -11
  5. package/buildScripts/webpack/buildThreads.mjs +7 -6
  6. package/buildScripts/webpack/json/build.json +4 -0
  7. package/examples/ServiceWorker.mjs +36 -0
  8. package/examples/component/coronaGallery/CountryGallery.mjs +12 -12
  9. package/examples/component/coronaGallery/CountryModel.mjs +8 -2
  10. package/examples/component/coronaGallery/CountryStore.mjs +12 -2
  11. package/examples/component/coronaGallery/MainContainer.mjs +3 -6
  12. package/examples/component/gallery/ImageModel.mjs +38 -0
  13. package/examples/component/gallery/ImageStore.mjs +32 -0
  14. package/examples/component/gallery/MainContainer.mjs +2 -0
  15. package/examples/component/helix/ImageModel.mjs +38 -0
  16. package/examples/component/helix/ImageStore.mjs +32 -0
  17. package/examples/component/helix/MainContainer.mjs +2 -0
  18. package/examples/component/helix/neo-config.json +2 -1
  19. package/examples/list/animate/MainStore.mjs +1 -1
  20. package/package.json +6 -6
  21. package/resources/scss/src/apps/covid/country/Gallery.scss +2 -1
  22. package/resources/scss/src/component/Gallery.scss +2 -1
  23. package/resources/scss/src/component/Helix.scss +7 -1
  24. package/resources/scss/src/examples/component/coronaGallery/CountryGallery.scss +2 -1
  25. package/src/DefaultConfig.mjs +10 -1
  26. package/src/Main.mjs +16 -12
  27. package/src/calendar/view/MainContainer.mjs +1 -1
  28. package/src/calendar/view/month/Component.mjs +8 -21
  29. package/src/component/Circle.mjs +39 -16
  30. package/src/component/Gallery.mjs +86 -112
  31. package/src/component/Helix.mjs +26 -40
  32. package/src/list/Base.mjs +2 -2
  33. package/src/main/addon/ServiceWorker.mjs +68 -0
  34. package/src/selection/CircleModel.mjs +3 -3
  35. package/src/selection/ListModel.mjs +2 -2
  36. package/src/worker/App.mjs +14 -18
  37. package/src/worker/Manager.mjs +10 -1
  38. package/src/worker/ServiceBase.mjs +298 -0
  39. package/src/worker/mixin/RemoteMethodAccess.mjs +1 -1
package/src/Main.mjs CHANGED
@@ -188,9 +188,11 @@ class Main extends core.Base {
188
188
  *
189
189
  */
190
190
  async onDomContentLoaded() {
191
- let me = this,
192
- config = Neo.config,
193
- imports = [];
191
+ let me = this,
192
+ config = Neo.config,
193
+ mainThreadAddons = config.mainThreadAddons,
194
+ imports = [],
195
+ modules;
194
196
 
195
197
  DomAccess.onDomContentLoaded();
196
198
 
@@ -203,18 +205,20 @@ class Main extends core.Base {
203
205
  __webpack_require__.p = config.basePath.substring(6);
204
206
  }
205
207
 
206
- config.mainThreadAddons.forEach(addon => {
207
- if (addon !== 'AnalyticsByGoogle') {
208
- imports.push(import(`./main/addon/${addon}.mjs`));
209
- }
210
- });
211
-
212
208
  // intended for the online examples where we need an easy way to add GA to every generated app
213
- if (config.useGoogleAnalytics || config.mainThreadAddons.includes('AnalyticsByGoogle')) {
214
- imports.push(import('./main/addon/AnalyticsByGoogle.mjs'));
209
+ if (config.useGoogleAnalytics && !mainThreadAddons.includes('AnalyticsByGoogle')) {
210
+ mainThreadAddons.push('AnalyticsByGoogle');
215
211
  }
216
212
 
217
- const modules = await Promise.all(imports);
213
+ if (config.useServiceWorker && !mainThreadAddons.includes('ServiceWorker')) {
214
+ mainThreadAddons.push('ServiceWorker');
215
+ }
216
+
217
+ mainThreadAddons.forEach(addon => {
218
+ imports.push(import(`./main/addon/${addon}.mjs`));
219
+ });
220
+
221
+ modules = await Promise.all(imports);
218
222
 
219
223
  me.addon = {};
220
224
 
@@ -500,7 +500,7 @@ class MainContainer extends Container {
500
500
  return import('./SettingsContainer.mjs').then(module => {
501
501
  me.items[1].add({
502
502
  module : module.default,
503
- collapsed : collapsed,
503
+ collapsed,
504
504
  removeInactiveCards: me.removeInactiveCards,
505
505
  style : {marginRight: !collapsed ? '0' : `-${me.settingsContainerWidth}px`},
506
506
  width : me.settingsContainerWidth,
@@ -554,10 +554,7 @@ class Component extends BaseComponent {
554
554
  date.setDate(date.getDate() + 1);
555
555
  }
556
556
 
557
- return {
558
- header: header,
559
- row : row
560
- }
557
+ return {header, row}
561
558
  }
562
559
 
563
560
  /**
@@ -626,16 +623,12 @@ class Component extends BaseComponent {
626
623
  let oldPath = data.oldPath,
627
624
  path = data.path;
628
625
 
629
- if (oldPath) {
630
- if (oldPath[0]?.cls.includes('neo-event')) {
631
- Neo.applyDeltas(this.appName, {id: oldPath[0].id, cls: {remove: ['neo-focus']}});
632
- }
626
+ if (oldPath?.[0]?.cls.includes('neo-event')) {
627
+ Neo.applyDeltas(this.appName, {id: oldPath[0].id, cls: {remove: ['neo-focus']}});
633
628
  }
634
629
 
635
- if (path) {
636
- if (path[0]?.cls.includes('neo-event')) {
637
- Neo.applyDeltas(this.appName, {id: path[0].id, cls: {add: ['neo-focus']}});
638
- }
630
+ if (path?.[0]?.cls.includes('neo-event')) {
631
+ Neo.applyDeltas(this.appName, {id: path[0].id, cls: {add: ['neo-focus']}});
639
632
  }
640
633
  }
641
634
 
@@ -668,9 +661,7 @@ class Component extends BaseComponent {
668
661
 
669
662
  week = me.createWeek(DateUtil.clone(date));
670
663
 
671
- if (week.header) {
672
- container.cn.push(week.header);
673
- }
664
+ week.header && container.cn.push(week.header);
674
665
 
675
666
  container.cn.push(week.row);
676
667
  }
@@ -702,9 +693,7 @@ class Component extends BaseComponent {
702
693
 
703
694
  container.cn.unshift(week.row);
704
695
 
705
- if (week.header) {
706
- container.cn.unshift(week.header);
707
- }
696
+ week.header && container.cn.unshift(week.header);
708
697
  }
709
698
 
710
699
  me.promiseVdomUpdate(me.vdom).then(() => {
@@ -723,9 +712,7 @@ class Component extends BaseComponent {
723
712
  me.vdom = vdom;
724
713
  }
725
714
 
726
- if (me.scrollTaskId) {
727
- clearTimeout(me.scrollTaskId);
728
- }
715
+ me.scrollTaskId && clearTimeout(me.scrollTaskId);
729
716
 
730
717
  me.scrollTaskId = setTimeout(me.onWheelEnd.bind(me), 300);
731
718
  }
@@ -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,44 +569,18 @@ 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
  /**
599
576
  * @param {Object} data
600
577
  */
601
578
  onMouseWheel(data) {
602
- let me = this,
603
- deltaX = data.deltaX,
604
- deltaY = data.deltaY,
605
- translateX = me.translateX,
606
- translateZ = me.translateZ;
579
+ let me = this;
607
580
 
608
581
  if (me.mouseWheelEnabled) {
609
- me._translateX = translateX - (deltaX * me.mouseWheelDeltaX); // silent update
610
- me._translateZ = translateZ + (deltaY * me.mouseWheelDeltaY); // silent update
582
+ me._translateX = me.translateX - (me.deltaX * me.mouseWheelDeltaX); // silent update
583
+ me._translateZ = me.translateZ + (me.deltaY * me.mouseWheelDeltaY); // silent update
611
584
 
612
585
  me.moveOrigin();
613
586
 
@@ -622,13 +595,14 @@ class Gallery extends Component {
622
595
  onSelectionChange(value) {
623
596
  let me = this,
624
597
  index = me.store.indexOf(value?.[0] || 0),
625
- imageHeight = me.imageHeight,
626
- imageWidth = me.imageWidth,
598
+ itemHeight = me.itemHeight,
599
+ itemWidth = me.itemWidth,
627
600
  vdom = me.vdom,
628
601
  camera = vdom.cn[0].cn[0],
602
+ cameraStyle = camera.style,
629
603
  dollyTransform = me.getCameraTransformForCell(index),
630
604
  height = me.offsetHeight / (me.amountRows + 2),
631
- width = Math.round(height * imageWidth / imageHeight),
605
+ width = Math.round(height * itemWidth / itemHeight),
632
606
  spacing = width + 10,
633
607
  timeoutId;
634
608
 
@@ -642,7 +616,7 @@ class Gallery extends Component {
642
616
  action : 'updateDom',
643
617
  appName: me.appName,
644
618
  deltas : {
645
- id : me.id + '__' + 'dolly',
619
+ id : me.id + '__dolly',
646
620
  style: {
647
621
  transform: me.translate3d(...dollyTransform)
648
622
  }
@@ -654,7 +628,7 @@ class Gallery extends Component {
654
628
  vnodeId : me.id,
655
629
  functions: [{
656
630
  fn : 'getComputedStyle',
657
- params : [me.id + '__' + 'dolly', null],
631
+ params : [me.id + '__dolly', null],
658
632
  paramIsDomNode: [true, false],
659
633
  scope : 'defaultView',
660
634
  returnFnName : 'transform',
@@ -665,20 +639,20 @@ class Gallery extends Component {
665
639
  translateX, angle;
666
640
 
667
641
  if (transform.indexOf('matrix3d') === 0) {
668
- transform = transform.substring(9, transform.length - 1); // remove matrix3d( ... )
669
- transform = transform.split(',').map(e => parseFloat(e));
642
+ transform = transform.substring(9, transform.length - 1); // remove matrix3d( ... )
643
+ transform = transform.split(',').map(e => parseFloat(e));
670
644
  translateX = transform[12]; // bottom left element of the 4x4 matrix
671
645
  } else {
672
- transform = transform.substring(7, transform.length - 1); // remove matrix( ... )
673
- transform = transform.split(',').map(e => parseFloat(e));
646
+ transform = transform.substring(7, transform.length - 1); // remove matrix( ... )
647
+ transform = transform.split(',').map(e => parseFloat(e));
674
648
  translateX = transform[4]; // bottom left element of the 2x3 matrix
675
649
  }
676
650
 
677
651
  translateX = translateX - dollyTransform[0];
678
652
  angle = Math.min(Math.max(translateX / (spacing * 3), -1), 1) * 45;
679
653
 
680
- camera.style.transform = 'rotateY(' + angle + 'deg)';
681
- camera.style.transitionDuration = '330ms';
654
+ cameraStyle.transform = `rotateY(${angle}deg)`;
655
+ cameraStyle.transitionDuration = '330ms';
682
656
 
683
657
  me.vdom = vdom;
684
658
 
@@ -687,8 +661,8 @@ class Gallery extends Component {
687
661
 
688
662
  vdom = me.vdom;
689
663
 
690
- camera.style.transform = 'rotateY(0deg)';
691
- camera.style.transitionDuration = '5000ms';
664
+ cameraStyle.transform = 'rotateY(0deg)';
665
+ cameraStyle.transitionDuration = '5000ms';
692
666
 
693
667
  me.vdom = vdom;
694
668
  }, 330);
@@ -739,7 +713,7 @@ class Gallery extends Component {
739
713
  }
740
714
 
741
715
  /**
742
- * @param {Array} items
716
+ * @param {Object[]} items
743
717
  */
744
718
  onStoreLoad(items) {
745
719
  this.getItemsRoot().cn = []; // silent update
@@ -780,7 +754,7 @@ class Gallery extends Component {
780
754
  * @returns {String}
781
755
  */
782
756
  translate3d(x, y, z) {
783
- return 'translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)';
757
+ return `translate3d(${x}px, ${y}px, ${z}px)`;
784
758
  }
785
759
  }
786
760