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.
- package/README.md +9 -0
- package/apps/covid/view/GalleryContainer.mjs +2 -2
- package/apps/covid/view/HelixContainer.mjs +2 -2
- package/apps/covid/view/TableContainer.mjs +2 -2
- package/apps/krausest/view/MainComponent.mjs +2 -2
- package/apps/krausest/view/TableComponent.mjs +2 -2
- package/apps/realworld/view/HomeComponent.mjs +2 -2
- package/apps/realworld/view/article/CommentComponent.mjs +2 -2
- package/apps/realworld/view/article/Component.mjs +2 -2
- package/apps/realworld/view/article/CreateCommentComponent.mjs +2 -2
- package/apps/realworld/view/article/CreateComponent.mjs +3 -3
- package/apps/realworld/view/article/PreviewComponent.mjs +2 -2
- package/apps/realworld/view/article/TagListComponent.mjs +2 -2
- package/apps/realworld/view/user/ProfileComponent.mjs +2 -2
- package/apps/realworld/view/user/SettingsComponent.mjs +2 -2
- package/apps/realworld/view/user/SignUpComponent.mjs +2 -2
- package/apps/realworld2/view/article/HelixContainer.mjs +2 -2
- package/apps/realworld2/view/article/PreviewComponent.mjs +2 -2
- package/apps/realworld2/view/article/TagListComponent.mjs +2 -2
- package/apps/realworld2/view/user/LoginFormContainer.mjs +2 -2
- package/apps/sharedcovid/view/GalleryContainer.mjs +2 -2
- package/apps/sharedcovid/view/HelixContainer.mjs +2 -2
- package/apps/sharedcovid/view/MainContainerController.mjs +12 -16
- package/apps/sharedcovid/view/TableContainer.mjs +2 -2
- package/apps/sharedcovid/view/mapboxGl/Container.mjs +2 -2
- package/apps/website/data/blog.json +13 -0
- package/docs/app/view/ContentTabContainer.mjs +2 -2
- package/docs/app/view/MainContainer.mjs +2 -2
- package/docs/app/view/classdetails/SourceViewComponent.mjs +2 -2
- package/docs/app/view/classdetails/TutorialComponent.mjs +2 -2
- package/docs/tutorials/02_ClassSystem.html +3 -3
- package/docs/tutorials/02_ClassSystem.md +2 -2
- package/docs/tutorials/09_TodoList_version1.html +8 -8
- package/examples/calendar/weekview/MainContainer.mjs +2 -2
- package/examples/component/coronaGallery/MainContainer.mjs +2 -2
- package/examples/component/coronaHelix/MainContainer.mjs +2 -2
- package/examples/component/gallery/MainContainer.mjs +2 -2
- package/examples/component/helix/MainContainer.mjs +2 -2
- package/examples/core/config/MainContainer.mjs +2 -2
- package/examples/dialog/MainContainer.mjs +2 -2
- package/examples/list/animate/List.mjs +8 -6
- package/examples/list/animate/MainContainer.mjs +36 -11
- package/examples/model/multiWindow/ViewportController.mjs +2 -2
- package/examples/todoList/version1/MainComponent.mjs +3 -3
- package/examples/todoList/version2/MainContainer.mjs +3 -3
- package/package.json +7 -7
- package/resources/scss/src/examples/list/animate/List.scss +1 -1
- package/src/Main.mjs +2 -2
- package/src/Neo.mjs +26 -25
- package/src/button/Split.mjs +2 -2
- package/src/calendar/view/EditEventContainer.mjs +2 -2
- package/src/calendar/view/MainContainer.mjs +2 -2
- package/src/calendar/view/MainContainerModel.mjs +2 -2
- package/src/calendar/view/SettingsContainer.mjs +2 -2
- package/src/calendar/view/YearComponent.mjs +3 -5
- package/src/calendar/view/calendars/EditContainer.mjs +2 -2
- package/src/calendar/view/month/Component.mjs +3 -5
- package/src/calendar/view/week/Component.mjs +3 -6
- package/src/calendar/view/week/EventDragZone.mjs +1 -3
- package/src/calendar/view/week/TimeAxisComponent.mjs +2 -2
- package/src/calendar/view/week/plugin/DragDrop.mjs +2 -2
- package/src/collection/Base.mjs +23 -6
- package/src/component/Base.mjs +13 -0
- package/src/component/Chip.mjs +2 -2
- package/src/component/Circle.mjs +2 -2
- package/src/component/DateSelector.mjs +4 -8
- package/src/component/Gallery.mjs +2 -2
- package/src/component/Helix.mjs +2 -2
- package/src/component/Splitter.mjs +3 -5
- package/src/component/mwc/Button.mjs +2 -2
- package/src/component/mwc/TextField.mjs +2 -2
- package/src/container/Panel.mjs +2 -2
- package/src/controller/Application.mjs +2 -2
- package/src/controller/Base.mjs +2 -2
- package/src/controller/Component.mjs +2 -2
- package/src/core/Base.mjs +25 -1
- package/src/core/IdGenerator.mjs +1 -1
- package/src/core/Observable.mjs +4 -0
- package/src/data/Store.mjs +2 -2
- package/src/dialog/Base.mjs +5 -14
- package/src/draggable/DragProxyComponent.mjs +2 -2
- package/src/draggable/DragZone.mjs +2 -2
- package/src/draggable/DropZone.mjs +2 -2
- package/src/draggable/list/DragZone.mjs +2 -2
- package/src/draggable/toolbar/DragZone.mjs +2 -2
- package/src/draggable/toolbar/SortZone.mjs +1 -3
- package/src/filter/ToggleOperatorsButton.mjs +2 -2
- package/src/form/field/CheckBox.mjs +2 -2
- package/src/form/field/Color.mjs +2 -2
- package/src/form/field/Date.mjs +2 -2
- package/src/form/field/Display.mjs +2 -2
- package/src/form/field/Picker.mjs +1 -3
- package/src/form/field/Range.mjs +2 -2
- package/src/form/field/Select.mjs +2 -2
- package/src/form/field/Text.mjs +3 -5
- package/src/form/field/Time.mjs +2 -2
- package/src/form/field/trigger/Base.mjs +2 -2
- package/src/form/field/trigger/Time.mjs +2 -2
- package/src/grid/Container.mjs +2 -2
- package/src/list/Base.mjs +5 -5
- package/src/list/plugin/Animate.mjs +105 -28
- package/src/main/DomAccess.mjs +2 -2
- package/src/main/DomEvents.mjs +2 -2
- package/src/main/addon/AmCharts.mjs +2 -2
- package/src/main/addon/AnalyticsByGoogle.mjs +2 -2
- package/src/main/addon/DragDrop.mjs +2 -2
- package/src/main/addon/HighlightJS.mjs +2 -2
- package/src/main/addon/MapboxGL.mjs +3 -2
- package/src/main/addon/Markdown.mjs +3 -3
- package/src/main/addon/Siesta.mjs +2 -2
- package/src/main/addon/Stylesheet.mjs +2 -2
- package/src/main/addon/WindowPosition.mjs +2 -2
- package/src/main/draggable/sensor/Mouse.mjs +2 -2
- package/src/main/draggable/sensor/Touch.mjs +2 -2
- package/src/manager/Component.mjs +2 -2
- package/src/manager/Instance.mjs +2 -2
- package/src/menu/List.mjs +4 -12
- package/src/model/Component.mjs +2 -2
- package/src/plugin/Base.mjs +2 -2
- package/src/plugin/Resizable.mjs +4 -7
- package/src/selection/table/CellColumnModel.mjs +2 -2
- package/src/selection/table/CellColumnRowModel.mjs +2 -2
- package/src/selection/table/CellRowModel.mjs +2 -2
- package/src/tab/Strip.mjs +1 -3
- package/src/table/Container.mjs +2 -2
- package/src/table/header/Button.mjs +2 -2
- package/src/util/Logger.mjs +2 -2
- package/src/worker/App.mjs +2 -2
- package/src/worker/Base.mjs +2 -2
- package/src/worker/Manager.mjs +2 -2
- package/test/siesta/siesta.js +2 -1
- package/test/siesta/tests/ClassConfigsAndFields.mjs +307 -0
- 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
|
-
|
|
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.');
|
package/src/container/Panel.mjs
CHANGED
|
@@ -48,13 +48,13 @@ class Application extends Base {
|
|
|
48
48
|
/**
|
|
49
49
|
* @param {Object} config
|
|
50
50
|
*/
|
|
51
|
-
|
|
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
|
|
package/src/controller/Base.mjs
CHANGED
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
|
-
|
|
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
|
package/src/core/IdGenerator.mjs
CHANGED
package/src/core/Observable.mjs
CHANGED
|
@@ -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
|
}
|
package/src/data/Store.mjs
CHANGED
package/src/dialog/Base.mjs
CHANGED
|
@@ -125,8 +125,8 @@ class Base extends Panel {
|
|
|
125
125
|
/**
|
|
126
126
|
* @param {Object} config
|
|
127
127
|
*/
|
|
128
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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, {
|
|
@@ -152,8 +152,8 @@ class DragZone extends Base {
|
|
|
152
152
|
/**
|
|
153
153
|
* @param {Object} config
|
|
154
154
|
*/
|
|
155
|
-
|
|
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);
|
|
@@ -204,9 +204,7 @@ class SortZone extends DragZone {
|
|
|
204
204
|
});
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
|
|
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`;
|
package/src/form/field/Color.mjs
CHANGED
package/src/form/field/Date.mjs
CHANGED
|
@@ -143,9 +143,7 @@ class Picker extends Text {
|
|
|
143
143
|
getClientRectsThenShow(callback, callbackScope) {
|
|
144
144
|
let me = this;
|
|
145
145
|
|
|
146
|
-
|
|
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
|
});
|
package/src/form/field/Range.mjs
CHANGED
package/src/form/field/Text.mjs
CHANGED
|
@@ -123,8 +123,8 @@ class Text extends Base {
|
|
|
123
123
|
/**
|
|
124
124
|
* @param {Object} config
|
|
125
125
|
*/
|
|
126
|
-
|
|
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 &&
|
|
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) {
|
package/src/form/field/Time.mjs
CHANGED
package/src/grid/Container.mjs
CHANGED
package/src/list/Base.mjs
CHANGED
|
@@ -105,8 +105,8 @@ class Base extends Component {
|
|
|
105
105
|
/**
|
|
106
106
|
* @param {Object} config
|
|
107
107
|
*/
|
|
108
|
-
|
|
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 :
|
|
195
|
-
load :
|
|
196
|
-
recordChange:
|
|
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
|
-
|
|
49
|
-
super(config);
|
|
53
|
+
construct(config) {
|
|
54
|
+
super.construct(config);
|
|
50
55
|
|
|
51
|
-
let me
|
|
56
|
+
let me = this,
|
|
57
|
+
owner = me.owner;
|
|
52
58
|
|
|
53
59
|
me.adjustCreateItem();
|
|
54
60
|
|
|
55
|
-
me.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
*
|
|
108
|
+
*
|
|
109
|
+
* @param {Object} record
|
|
110
|
+
* @param {Number} index
|
|
111
|
+
* @returns {{x: Number, y: Number}}
|
|
110
112
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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);
|