neo.mjs 2.3.18 → 3.0.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 (133) hide show
  1. package/README.md +9 -0
  2. package/apps/covid/view/GalleryContainer.mjs +2 -2
  3. package/apps/covid/view/HelixContainer.mjs +2 -2
  4. package/apps/covid/view/TableContainer.mjs +2 -2
  5. package/apps/krausest/view/MainComponent.mjs +2 -2
  6. package/apps/krausest/view/TableComponent.mjs +2 -2
  7. package/apps/realworld/view/HomeComponent.mjs +2 -2
  8. package/apps/realworld/view/article/CommentComponent.mjs +2 -2
  9. package/apps/realworld/view/article/Component.mjs +2 -2
  10. package/apps/realworld/view/article/CreateCommentComponent.mjs +2 -2
  11. package/apps/realworld/view/article/CreateComponent.mjs +3 -3
  12. package/apps/realworld/view/article/PreviewComponent.mjs +2 -2
  13. package/apps/realworld/view/article/TagListComponent.mjs +2 -2
  14. package/apps/realworld/view/user/ProfileComponent.mjs +2 -2
  15. package/apps/realworld/view/user/SettingsComponent.mjs +2 -2
  16. package/apps/realworld/view/user/SignUpComponent.mjs +2 -2
  17. package/apps/realworld2/view/article/HelixContainer.mjs +2 -2
  18. package/apps/realworld2/view/article/PreviewComponent.mjs +2 -2
  19. package/apps/realworld2/view/article/TagListComponent.mjs +2 -2
  20. package/apps/realworld2/view/user/LoginFormContainer.mjs +2 -2
  21. package/apps/sharedcovid/view/GalleryContainer.mjs +2 -2
  22. package/apps/sharedcovid/view/HelixContainer.mjs +2 -2
  23. package/apps/sharedcovid/view/MainContainerController.mjs +12 -16
  24. package/apps/sharedcovid/view/TableContainer.mjs +2 -2
  25. package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -2
  26. package/apps/website/data/blog.json +13 -0
  27. package/docs/app/view/ContentTabContainer.mjs +2 -2
  28. package/docs/app/view/MainContainer.mjs +2 -2
  29. package/docs/app/view/classdetails/SourceViewComponent.mjs +2 -2
  30. package/docs/app/view/classdetails/TutorialComponent.mjs +2 -2
  31. package/docs/tutorials/02_ClassSystem.html +3 -3
  32. package/docs/tutorials/02_ClassSystem.md +2 -2
  33. package/docs/tutorials/09_TodoList_version1.html +8 -8
  34. package/examples/calendar/weekview/MainContainer.mjs +2 -2
  35. package/examples/component/coronaGallery/MainContainer.mjs +2 -2
  36. package/examples/component/coronaHelix/MainContainer.mjs +2 -2
  37. package/examples/component/gallery/MainContainer.mjs +2 -2
  38. package/examples/component/helix/MainContainer.mjs +2 -2
  39. package/examples/core/config/MainContainer.mjs +2 -2
  40. package/examples/dialog/MainContainer.mjs +2 -2
  41. package/examples/list/animate/List.mjs +8 -6
  42. package/examples/list/animate/MainContainer.mjs +36 -11
  43. package/examples/model/multiWindow/ViewportController.mjs +2 -2
  44. package/examples/todoList/version1/MainComponent.mjs +3 -3
  45. package/examples/todoList/version2/MainContainer.mjs +3 -3
  46. package/package.json +7 -7
  47. package/resources/scss/src/examples/list/animate/List.scss +1 -1
  48. package/src/Main.mjs +2 -2
  49. package/src/Neo.mjs +26 -25
  50. package/src/button/Split.mjs +2 -2
  51. package/src/calendar/view/EditEventContainer.mjs +2 -2
  52. package/src/calendar/view/MainContainer.mjs +2 -2
  53. package/src/calendar/view/MainContainerModel.mjs +2 -2
  54. package/src/calendar/view/SettingsContainer.mjs +2 -2
  55. package/src/calendar/view/YearComponent.mjs +3 -5
  56. package/src/calendar/view/calendars/EditContainer.mjs +2 -2
  57. package/src/calendar/view/month/Component.mjs +3 -5
  58. package/src/calendar/view/week/Component.mjs +3 -6
  59. package/src/calendar/view/week/EventDragZone.mjs +1 -3
  60. package/src/calendar/view/week/TimeAxisComponent.mjs +2 -2
  61. package/src/calendar/view/week/plugin/DragDrop.mjs +2 -2
  62. package/src/collection/Base.mjs +23 -6
  63. package/src/component/Base.mjs +13 -0
  64. package/src/component/Chip.mjs +2 -2
  65. package/src/component/Circle.mjs +2 -2
  66. package/src/component/DateSelector.mjs +4 -8
  67. package/src/component/Gallery.mjs +2 -2
  68. package/src/component/Helix.mjs +2 -2
  69. package/src/component/Splitter.mjs +3 -5
  70. package/src/component/mwc/Button.mjs +2 -2
  71. package/src/component/mwc/TextField.mjs +2 -2
  72. package/src/container/Panel.mjs +2 -2
  73. package/src/controller/Application.mjs +2 -2
  74. package/src/controller/Base.mjs +2 -2
  75. package/src/controller/Component.mjs +2 -2
  76. package/src/core/Base.mjs +25 -1
  77. package/src/core/IdGenerator.mjs +1 -1
  78. package/src/core/Observable.mjs +4 -0
  79. package/src/data/Store.mjs +2 -2
  80. package/src/dialog/Base.mjs +5 -14
  81. package/src/draggable/DragProxyComponent.mjs +2 -2
  82. package/src/draggable/DragZone.mjs +2 -2
  83. package/src/draggable/DropZone.mjs +2 -2
  84. package/src/draggable/list/DragZone.mjs +2 -2
  85. package/src/draggable/toolbar/DragZone.mjs +2 -2
  86. package/src/draggable/toolbar/SortZone.mjs +1 -3
  87. package/src/filter/ToggleOperatorsButton.mjs +2 -2
  88. package/src/form/field/CheckBox.mjs +2 -2
  89. package/src/form/field/Color.mjs +2 -2
  90. package/src/form/field/Date.mjs +2 -2
  91. package/src/form/field/Display.mjs +2 -2
  92. package/src/form/field/Picker.mjs +1 -3
  93. package/src/form/field/Range.mjs +2 -2
  94. package/src/form/field/Select.mjs +2 -2
  95. package/src/form/field/Text.mjs +3 -5
  96. package/src/form/field/Time.mjs +2 -2
  97. package/src/form/field/trigger/Base.mjs +2 -2
  98. package/src/form/field/trigger/Time.mjs +2 -2
  99. package/src/grid/Container.mjs +2 -2
  100. package/src/list/Base.mjs +5 -5
  101. package/src/list/plugin/Animate.mjs +105 -28
  102. package/src/main/DomAccess.mjs +2 -2
  103. package/src/main/DomEvents.mjs +2 -2
  104. package/src/main/addon/AmCharts.mjs +2 -2
  105. package/src/main/addon/AnalyticsByGoogle.mjs +2 -2
  106. package/src/main/addon/DragDrop.mjs +2 -2
  107. package/src/main/addon/HighlightJS.mjs +2 -2
  108. package/src/main/addon/MapboxGL.mjs +3 -2
  109. package/src/main/addon/Markdown.mjs +3 -3
  110. package/src/main/addon/Siesta.mjs +2 -2
  111. package/src/main/addon/Stylesheet.mjs +2 -2
  112. package/src/main/addon/WindowPosition.mjs +2 -2
  113. package/src/main/draggable/sensor/Mouse.mjs +2 -2
  114. package/src/main/draggable/sensor/Touch.mjs +2 -2
  115. package/src/manager/Component.mjs +2 -2
  116. package/src/manager/Instance.mjs +2 -2
  117. package/src/menu/List.mjs +4 -12
  118. package/src/model/Component.mjs +2 -2
  119. package/src/plugin/Base.mjs +2 -2
  120. package/src/plugin/Resizable.mjs +4 -7
  121. package/src/selection/table/CellColumnModel.mjs +2 -2
  122. package/src/selection/table/CellColumnRowModel.mjs +2 -2
  123. package/src/selection/table/CellRowModel.mjs +2 -2
  124. package/src/tab/Strip.mjs +1 -3
  125. package/src/table/Container.mjs +2 -2
  126. package/src/table/header/Button.mjs +2 -2
  127. package/src/util/Logger.mjs +2 -2
  128. package/src/worker/App.mjs +2 -2
  129. package/src/worker/Base.mjs +2 -2
  130. package/src/worker/Manager.mjs +2 -2
  131. package/test/siesta/siesta.js +2 -1
  132. package/test/siesta/tests/ClassConfigsAndFields.mjs +307 -0
  133. package/test/siesta/tests/ClassSystem.mjs +1 -1
@@ -65,8 +65,8 @@ class TextField extends Component {
65
65
  /**
66
66
  * @param {Object} config
67
67
  */
68
- constructor(config) {
69
- super(config);
68
+ construct(config) {
69
+ super.construct(config);
70
70
 
71
71
  if (!Neo.config.mainThreadAddons.includes('Mwc')) {
72
72
  console.error('Please include "Mwc" into the mainThreadAddons of your neo-config.json file.');
@@ -50,8 +50,8 @@ class Panel extends Container {
50
50
  /**
51
51
  * @param {Object} config
52
52
  */
53
- constructor(config) {
54
- super(config);
53
+ construct(config) {
54
+ super.construct(config);
55
55
 
56
56
  let me = this;
57
57
 
@@ -48,13 +48,13 @@ class Application extends Base {
48
48
  /**
49
49
  * @param {Object} config
50
50
  */
51
- constructor(config) {
51
+ construct(config) {
52
52
  // to guarantee that the main view can access Neo.apps at any point,
53
53
  // we need to trigger its assignment at the end of the ctor.
54
54
  let mainView = config.mainView;
55
55
  delete config.mainView;
56
56
 
57
- super(config);
57
+ super.construct(config);
58
58
 
59
59
  let me = this;
60
60
 
@@ -30,8 +30,8 @@ class Base extends CoreBase {
30
30
  /**
31
31
  * @param {Object} config
32
32
  */
33
- constructor(config) {
34
- super(config);
33
+ construct(config) {
34
+ super.construct(config);
35
35
 
36
36
  HashHistory.on('change', this.onHashChange, this);
37
37
  }
@@ -38,8 +38,8 @@ class Component extends Base {
38
38
  /**
39
39
  * @param {Object} config
40
40
  */
41
- constructor(config) {
42
- super(config);
41
+ construct(config) {
42
+ super.construct(config);
43
43
 
44
44
  let me = this,
45
45
  component = me.component,
package/src/core/Base.mjs CHANGED
@@ -74,7 +74,7 @@ class Base {
74
74
  * Applies the observable mixin if needed, grants remote access if needed.
75
75
  * @param {Object} config={}
76
76
  */
77
- constructor(config={}) {
77
+ construct(config={}) {
78
78
  let me = this;
79
79
 
80
80
  Object.defineProperties(me, {
@@ -99,6 +99,9 @@ class Base {
99
99
 
100
100
  me.getStaticConfig('observable') && me.initObservable(config);
101
101
 
102
+ // assign class field values prior to configs
103
+ config = me.setFields(config);
104
+
102
105
  me.initConfig(config);
103
106
 
104
107
  Object.defineProperty(me, 'configsApplied', {
@@ -376,6 +379,8 @@ class Base {
376
379
  set(values={}) {
377
380
  let me = this;
378
381
 
382
+ values = me.setFields(values);
383
+
379
384
  // If the initial config processing is still running,
380
385
  // finish this one first before dropping new values into the configSymbol.
381
386
  // see: https://github.com/neomjs/neo/issues/2201
@@ -388,6 +393,25 @@ class Base {
388
393
  me.processConfigs(true);
389
394
  }
390
395
 
396
+ /**
397
+ * We want to assign class fields first and remove them from the config object,
398
+ * so that afterSet(), beforeGet() and beforeSet() methods can get the new values right away
399
+ * @param {Object} config
400
+ * @returns {Object}
401
+ */
402
+ setFields(config) {
403
+ let configNames = this.constructor.config;
404
+
405
+ Object.entries(config).forEach(([key, value]) => {
406
+ if (!configNames.hasOwnProperty(key) && !Neo.hasPropertySetter(this, key)) {
407
+ this[key] = value;
408
+ delete config[key];
409
+ }
410
+ });
411
+
412
+ return config;
413
+ }
414
+
391
415
  /**
392
416
  * Sets the value of a static config by a given key
393
417
  * @param {String} key The key of a staticConfig defined inside static getStaticConfig
@@ -42,7 +42,7 @@ class IdGenerator {
42
42
  /**
43
43
  * @param config
44
44
  */
45
- constructor(config) {
45
+ construct(config) {
46
46
  let me = this;
47
47
 
48
48
  me.idCounter = {};
@@ -107,6 +107,10 @@ class Observable extends Base {
107
107
  for (i = 0; i < len; i++) {
108
108
  eventConfig = events[i];
109
109
 
110
+ if (!Neo.isFunction(eventConfig.fn)) {
111
+ eventConfig.fn = eventConfig.scope[eventConfig.fn];
112
+ }
113
+
110
114
  eventConfig.fn.apply(eventConfig.scope || me, eventConfig.data ? args.concat(eventConfig.data) : args);
111
115
  }
112
116
  }
@@ -79,8 +79,8 @@ class Store extends Base {
79
79
  /**
80
80
  * @param {Object} config
81
81
  */
82
- constructor(config) {
83
- super(config);
82
+ construct(config) {
83
+ super.construct(config);
84
84
 
85
85
  let me = this;
86
86
 
@@ -125,8 +125,8 @@ class Base extends Panel {
125
125
  /**
126
126
  * @param {Object} config
127
127
  */
128
- constructor(config) {
129
- super(config);
128
+ construct(config) {
129
+ super.construct(config);
130
130
 
131
131
  let me = this;
132
132
 
@@ -286,10 +286,7 @@ class Base extends Panel {
286
286
  appName = me.appName,
287
287
  id = me.getAnimateTargetId();
288
288
 
289
- Neo.main.DomAccess.getBoundingClientRect({
290
- appName: appName,
291
- id : [me.id, me.animateTargetId]
292
- }).then(rects => {
289
+ me.getDomRect([me.id, me.animateTargetId]).then(rects => {
293
290
  Neo.currentWorker.promiseMessage('main', {
294
291
  action : 'mountDom',
295
292
  appName : appName,
@@ -336,10 +333,7 @@ class Base extends Panel {
336
333
  appName = me.appName,
337
334
  id = me.getAnimateTargetId();
338
335
 
339
- Neo.main.DomAccess.getBoundingClientRect({
340
- appName: appName,
341
- id : me.animateTargetId
342
- }).then(rect => {
336
+ me.getDomRect(me.animateTargetId).then(rect => {
343
337
  Neo.currentWorker.promiseMessage('main', {
344
338
  action : 'mountDom',
345
339
  appName : appName,
@@ -530,10 +524,7 @@ class Base extends Panel {
530
524
  initialTransitionProperty, wrapperStyle;
531
525
 
532
526
  if (!me.maximized) {
533
- Neo.main.DomAccess.getBoundingClientRect({
534
- appName: me.appName,
535
- id : me.dragZone.dragProxy.id
536
- }).then(rect => {
527
+ me.getDomRect(me.dragZone.dragProxy.id).then(rect => {
537
528
  wrapperStyle = me.wrapperStyle;
538
529
 
539
530
  Object.assign(wrapperStyle, {
@@ -37,8 +37,8 @@ class DragProxyComponent extends Base {
37
37
  /**
38
38
  * @param {Object} config
39
39
  */
40
- constructor(config) {
41
- super(config);
40
+ construct(config) {
41
+ super.construct(config);
42
42
 
43
43
  let me = this;
44
44
 
@@ -152,8 +152,8 @@ class DragZone extends Base {
152
152
  /**
153
153
  * @param {Object} config
154
154
  */
155
- constructor(config) {
156
- super(config);
155
+ construct(config) {
156
+ super.construct(config);
157
157
 
158
158
  if (!Neo.main.addon.DragDrop) {
159
159
  console.error('You can not use Neo.draggable.DragZone without adding Neo.main.addon.DragDrop to the main thread addons', this.id);
@@ -25,8 +25,8 @@ class DropZone extends Base {
25
25
  /**
26
26
  * @param {Object} config
27
27
  */
28
- constructor(config) {
29
- super(config);
28
+ construct(config) {
29
+ super.construct(config);
30
30
 
31
31
  let me = this,
32
32
  owner = me.owner,
@@ -29,8 +29,8 @@ class DragZone extends BaseDragZone {
29
29
  /**
30
30
  * @param {Object} config
31
31
  */
32
- constructor(config) {
33
- super(config);
32
+ construct(config) {
33
+ super.construct(config);
34
34
 
35
35
  let me = this,
36
36
  owner = me.owner,
@@ -23,8 +23,8 @@ class DragZone extends BaseDragZone {
23
23
  /**
24
24
  * @param {Object} config
25
25
  */
26
- constructor(config) {
27
- super(config);
26
+ construct(config) {
27
+ super.construct(config);
28
28
 
29
29
  let me = this,
30
30
  owner = me.owner,
@@ -204,9 +204,7 @@ class SortZone extends DragZone {
204
204
  });
205
205
  });
206
206
 
207
- Neo.main.DomAccess.getBoundingClientRect({
208
- id: [owner.id].concat(owner.items.map(e => e.id))
209
- }).then(itemRects => {
207
+ owner.getDomRect([owner.id].concat(owner.items.map(e => e.id))).then(itemRects => {
210
208
  me.ownerRect = itemRects[0];
211
209
 
212
210
  ownerStyle.height = `${itemRects[0].height}px`;
@@ -30,8 +30,8 @@ class ToggleOperatorsButton extends Button {
30
30
  /**
31
31
  * @param {Object} config
32
32
  */
33
- constructor(config) {
34
- super(config);
33
+ construct(config) {
34
+ super.construct(config);
35
35
 
36
36
  let me = this;
37
37
 
@@ -72,8 +72,8 @@ class CheckBox extends Base {
72
72
  /**
73
73
  * @param {Object} config
74
74
  */
75
- constructor(config) {
76
- super(config);
75
+ construct(config) {
76
+ super.construct(config);
77
77
 
78
78
  let me = this,
79
79
  domListeners = me.domListeners;
@@ -47,8 +47,8 @@ class Color extends Select {
47
47
  /**
48
48
  * @param {Object} config
49
49
  */
50
- constructor(config) {
51
- super(config);
50
+ construct(config) {
51
+ super.construct(config);
52
52
 
53
53
  let me = this,
54
54
  vdom = me.vdom,
@@ -62,8 +62,8 @@ class DateField extends Picker {
62
62
  /**
63
63
  * @param config
64
64
  */
65
- constructor(config) {
66
- super(config);
65
+ construct(config) {
66
+ super.construct(config);
67
67
 
68
68
  let me = this;
69
69
 
@@ -31,8 +31,8 @@ class Display extends Text {
31
31
  /**
32
32
  * @param {Object} config
33
33
  */
34
- constructor(config) {
35
- super(config);
34
+ construct(config) {
35
+ super.construct(config);
36
36
 
37
37
  let me = this,
38
38
  vdom = me.vdom,
@@ -143,9 +143,7 @@ class Picker extends Text {
143
143
  getClientRectsThenShow(callback, callbackScope) {
144
144
  let me = this;
145
145
 
146
- Neo.main.DomAccess.getBoundingClientRect({
147
- id: [me.id, me.getInputWrapperId(), 'body']
148
- }).then(data => {
146
+ me.getDomRect([me.id, me.getInputWrapperId(), 'body']).then(data => {
149
147
  me.clientRects = data;
150
148
  me.showPicker(callback, callbackScope);
151
149
  });
@@ -48,8 +48,8 @@ class Range extends Number {
48
48
  /**
49
49
  * @param {Object} config
50
50
  */
51
- constructor(config) {
52
- super(config);
51
+ construct(config) {
52
+ super.construct(config);
53
53
 
54
54
  let me = this,
55
55
  domListeners = me.domListeners,
@@ -105,8 +105,8 @@ class Select extends Picker {
105
105
  /**
106
106
  * @param {Object} config
107
107
  */
108
- constructor(config) {
109
- super(config);
108
+ construct(config) {
109
+ super.construct(config);
110
110
 
111
111
  let me = this;
112
112
 
@@ -123,8 +123,8 @@ class Text extends Base {
123
123
  /**
124
124
  * @param {Object} config
125
125
  */
126
- constructor(config) {
127
- super(config);
126
+ construct(config) {
127
+ super.construct(config);
128
128
 
129
129
  let me = this,
130
130
  domListeners = me.domListeners;
@@ -921,9 +921,7 @@ class Text extends Base {
921
921
  updateCenterBorderElWidth(silent=false) {
922
922
  let me = this;
923
923
 
924
- me.mounted && Neo.main.DomAccess.getBoundingClientRect({
925
- id: me.getCenterBorderEl().id
926
- }).then(data => {
924
+ me.mounted && me.getDomRect(me.getCenterBorderEl().id).then(data => {
927
925
  me.centerBorderElWidth = Math.round(data.width * .7) + 8;
928
926
 
929
927
  if (!silent) {
@@ -84,8 +84,8 @@ class Time extends Picker {
84
84
  /**
85
85
  * @param {Object} config
86
86
  */
87
- constructor(config) {
88
- super(config);
87
+ construct(config) {
88
+ super.construct(config);
89
89
 
90
90
  let me = this,
91
91
  clearTrigger = me.getTrigger('clear');
@@ -82,8 +82,8 @@ class Base extends Component {
82
82
  /**
83
83
  * @param {Object} config
84
84
  */
85
- constructor(config) {
86
- super(config);
85
+ construct(config) {
86
+ super.construct(config);
87
87
 
88
88
  let me = this,
89
89
  domListeners = me.domListeners || [],
@@ -50,8 +50,8 @@ class Time extends Picker {
50
50
  /**
51
51
  * @param {Object} config
52
52
  */
53
- constructor(config) {
54
- super(config);
53
+ construct(config) {
54
+ super.construct(config);
55
55
 
56
56
  let me = this,
57
57
  vdom = me.vdom;
@@ -76,8 +76,8 @@ class Container extends BaseContainer {
76
76
  /**
77
77
  * @param {Object} config
78
78
  */
79
- constructor(config) {
80
- super(config);
79
+ construct(config) {
80
+ super.construct(config);
81
81
 
82
82
  this.createRandomViewData(this.amountRows);
83
83
  }
package/src/list/Base.mjs CHANGED
@@ -105,8 +105,8 @@ class Base extends Component {
105
105
  /**
106
106
  * @param {Object} config
107
107
  */
108
- constructor(config) {
109
- super(config);
108
+ construct(config) {
109
+ super.construct(config);
110
110
 
111
111
  let me = this,
112
112
  domListeners = me.domListeners;
@@ -191,9 +191,9 @@ class Base extends Component {
191
191
  let me = this;
192
192
 
193
193
  value?.on({
194
- filter : me.onStoreFilter,
195
- load : me.onStoreLoad,
196
- recordChange: me.onStoreRecordChange,
194
+ filter : 'onStoreFilter',
195
+ load : 'onStoreLoad',
196
+ recordChange: 'onStoreRecordChange',
197
197
  scope : me
198
198
  });
199
199
 
@@ -39,23 +39,30 @@ class Animate extends Base {
39
39
  * Read only
40
40
  * @member {Number|null} rows=null
41
41
  */
42
- rows: null
42
+ rows: null,
43
+ /**
44
+ * Time in ms. Please ensure to match the CSS based value, in case you change the default.
45
+ * @member {Number} transitionDuration=500
46
+ */
47
+ transitionDuration: 500
43
48
  }}
44
49
 
45
50
  /**
46
51
  * @param {Object} config
47
52
  */
48
- constructor(config) {
49
- super(config);
53
+ construct(config) {
54
+ super.construct(config);
50
55
 
51
- let me = this;
56
+ let me = this,
57
+ owner = me.owner;
52
58
 
53
59
  me.adjustCreateItem();
54
60
 
55
- me.owner.store.on({
56
- filter: me.onFilter,
57
- sort : me.onSort,
58
- scope : me
61
+ owner.onStoreFilter = me.onStoreFilter.bind(me);
62
+
63
+ owner.store.on({
64
+ sort : me.onSort,
65
+ scope: me
59
66
  });
60
67
  }
61
68
 
@@ -77,27 +84,19 @@ class Animate extends Base {
77
84
  * @returns {Object}
78
85
  */
79
86
  createItem(me, record, index) {
80
- let item = me.ownerCreateItem(record, index),
81
- itemHeight = me.itemHeight,
82
- itemWidth = me.itemWidth,
83
- margin = me.itemMargin,
84
- style = item.style || {},
85
- column, row, x, y;
87
+ let item = me.ownerCreateItem(record, index),
88
+ position = me.getItemPosition(record, index),
89
+ style = item.style || {};
86
90
 
87
91
  if (!me.ownerRect) {
88
92
  return null;
89
93
  }
90
94
 
91
- column = index % me.columns;
92
- row = Math.floor(index / me.columns);
93
- x = column * (margin + itemWidth) + margin;
94
- y = row * (margin + itemHeight) + margin;
95
-
96
95
  Object.assign(style, {
97
- height : `${itemHeight}px`,
96
+ height : `${me.itemHeight}px`,
98
97
  position : 'absolute',
99
- transform: `translate(${x}px, ${y}px)`,
100
- width : `${itemWidth}px`
98
+ transform: `translate(${position.x}px, ${position.y}px)`,
99
+ width : `${me.itemWidth}px`
101
100
  });
102
101
 
103
102
  item.style = style;
@@ -106,10 +105,20 @@ class Animate extends Base {
106
105
  }
107
106
 
108
107
  /**
109
- * @param {Object} data
108
+ *
109
+ * @param {Object} record
110
+ * @param {Number} index
111
+ * @returns {{x: Number, y: Number}}
110
112
  */
111
- onFilter(data) {
112
- console.log('onFilter', data);
113
+ getItemPosition(record, index) {
114
+ let me = this,
115
+ column = index % me.columns,
116
+ margin = me.itemMargin,
117
+ row = Math.floor(index / me.columns),
118
+ x = column * (margin + me.itemWidth) + margin,
119
+ y = row * (margin + me.itemHeight) + margin;
120
+
121
+ return {x, y};
113
122
  }
114
123
 
115
124
  /**
@@ -118,9 +127,7 @@ class Animate extends Base {
118
127
  onOwnerMounted() {
119
128
  let me = this;
120
129
 
121
- Neo.main.DomAccess.getBoundingClientRect({
122
- id: me.owner.id
123
- }).then(rect => {
130
+ me.owner.getDomRect().then(rect => {
124
131
  Object.assign(me, {
125
132
  columns : Math.floor(rect.width / me.itemWidth),
126
133
  ownerRect: rect,
@@ -169,6 +176,76 @@ class Animate extends Base {
169
176
  }
170
177
  }
171
178
  }
179
+
180
+ /**
181
+ * @param {Object} data
182
+ * @param {Boolean} data.isFiltered
183
+ * @param {Object[]} data.items
184
+ * @param {Object[]} data.oldItems
185
+ * @param {Neo.data.Store} data.scope
186
+ */
187
+ onStoreFilter(data) {
188
+ let me = this,
189
+ owner = me.owner,
190
+ addedItems = [],
191
+ movedItems = [],
192
+ removedItems = [],
193
+ vdom = owner.vdom,
194
+ index, map, position;
195
+
196
+ data.items.forEach((record, index) => {
197
+ if (!data.oldItems.includes(record)) {
198
+ addedItems.push({index, record});
199
+ } else {
200
+ movedItems.push({index, record});
201
+ }
202
+ });
203
+
204
+ data.oldItems.forEach((record, index) => {
205
+ if (!data.items.includes(record)) {
206
+ removedItems.push({index, record});
207
+ }
208
+ });
209
+
210
+ addedItems.forEach(obj => {
211
+ vdom.cn.splice(obj.index, 0, me.createItem(me, obj.record, obj.index));
212
+
213
+ obj.item = vdom.cn[obj.index];
214
+ obj.item.style.opacity = 0;
215
+ });
216
+
217
+ owner.vdom = vdom;
218
+
219
+ // ensure to get into the next animation frame
220
+ setTimeout(() => {
221
+ vdom = owner.vdom;
222
+
223
+ addedItems.forEach(obj => {
224
+ vdom.cn[obj.index].style.opacity = 1;
225
+ });
226
+
227
+ // new items are already added into the vdom, while old items are not yet removed
228
+ // => we need a map to ensure getting the correct index
229
+ map = vdom.cn.map(e => e.id);
230
+
231
+ movedItems.forEach(obj => {
232
+ index = map.indexOf(owner.getItemId(obj.record[owner.store.keyProperty]));
233
+ position = me.getItemPosition(obj.record, obj.index);
234
+ vdom.cn[index].style.transform = `translate(${position.x}px, ${position.y}px)`;
235
+ });
236
+
237
+ removedItems.forEach(obj => {
238
+ obj.item = vdom.cn[obj.index];
239
+ obj.item.style.opacity = 0;
240
+ });
241
+
242
+ owner.vdom = vdom;
243
+
244
+ setTimeout(() => {
245
+ owner.createItems();
246
+ }, me.transitionDuration);
247
+ }, 50);
248
+ }
172
249
  }
173
250
 
174
251
  Neo.applyClassConfig(Animate);
@@ -78,8 +78,8 @@ class DomAccess extends Base {
78
78
  /**
79
79
  * @param {Object} config
80
80
  */
81
- constructor(config) {
82
- super(config);
81
+ construct(config) {
82
+ super.construct(config);
83
83
 
84
84
  let me = this,
85
85
  node;