neo.mjs 2.3.13 → 2.3.17
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 +8 -16
- package/apps/covid/view/HeaderContainer.mjs +1 -3
- package/apps/covid/view/HelixContainer.mjs +1 -1
- package/apps/covid/view/MainContainer.mjs +1 -1
- package/apps/covid/view/MainContainerController.mjs +3 -20
- package/apps/covid/view/TableContainerController.mjs +8 -8
- package/apps/covid/view/country/Table.mjs +1 -3
- package/apps/realworld/api/config.mjs +2 -2
- package/apps/sharedcovid/view/GalleryContainer.mjs +7 -0
- package/apps/sharedcovid/view/HeaderContainer.mjs +6 -3
- package/apps/sharedcovid/view/HelixContainer.mjs +8 -1
- package/apps/sharedcovid/view/MainContainer.mjs +7 -2
- package/apps/sharedcovid/view/MainContainerController.mjs +48 -134
- package/apps/sharedcovid/view/MainContainerModel.mjs +51 -0
- package/apps/sharedcovid/view/TableContainer.mjs +24 -0
- package/apps/sharedcovid/view/TableContainerController.mjs +26 -39
- package/apps/sharedcovid/view/country/Gallery.mjs +36 -2
- package/apps/sharedcovid/view/country/Helix.mjs +37 -1
- package/apps/sharedcovid/view/country/Table.mjs +65 -1
- package/apps/sharedcovid/view/mapboxGl/Container.mjs +24 -4
- package/apps/website/data/blog.json +17 -4
- package/apps/website/data/examples_devmode.json +18 -18
- package/buildScripts/webpack/development/webpack.config.main.js +2 -1
- package/buildScripts/webpack/production/webpack.config.main.js +2 -1
- package/examples/list/animate/List.mjs +50 -0
- package/examples/list/animate/MainContainer.mjs +79 -0
- package/examples/list/animate/MainModel.mjs +33 -0
- package/examples/list/animate/MainStore.mjs +31 -0
- package/examples/list/animate/app.mjs +8 -0
- package/examples/list/animate/index.html +11 -0
- package/examples/list/animate/neo-config.json +7 -0
- package/examples/list/base/neo-config.json +1 -1
- package/package.json +11 -11
- package/resources/scss/src/examples/list/animate/List.scss +30 -0
- package/src/Main.mjs +0 -8
- package/src/Neo.mjs +1 -3
- package/src/calendar/view/week/Component.mjs +1 -1
- package/src/collection/Base.mjs +7 -4
- package/src/component/Base.mjs +4 -11
- package/src/core/Base.mjs +1 -1
- package/src/list/Base.mjs +39 -8
- package/src/list/plugin/Animate.mjs +177 -0
- package/src/model/Component.mjs +3 -14
- package/src/worker/Manager.mjs +6 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import Base from '../../plugin/Base.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class Neo.list.plugin.Animate
|
|
5
|
+
* @extends Neo.plugin.Base
|
|
6
|
+
*/
|
|
7
|
+
class Animate extends Base {
|
|
8
|
+
static getConfig() {return {
|
|
9
|
+
/**
|
|
10
|
+
* @member {String} className='Neo.list.plugin.Animate'
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
className: 'Neo.list.plugin.Animate',
|
|
14
|
+
/**
|
|
15
|
+
* Read only
|
|
16
|
+
* @member {Number|null} columns=null
|
|
17
|
+
*/
|
|
18
|
+
columns: null,
|
|
19
|
+
/**
|
|
20
|
+
* Value in px
|
|
21
|
+
* @member {Number} itemHeight=200
|
|
22
|
+
*/
|
|
23
|
+
itemHeight: 200,
|
|
24
|
+
/**
|
|
25
|
+
* Value in px
|
|
26
|
+
* @member {Number} itemMargin=10
|
|
27
|
+
*/
|
|
28
|
+
itemMargin: 10,
|
|
29
|
+
/**
|
|
30
|
+
* Value in px
|
|
31
|
+
* @member {Number} itemWidth=300
|
|
32
|
+
*/
|
|
33
|
+
itemWidth: 300,
|
|
34
|
+
/**
|
|
35
|
+
* @member {DOMRect|null} ownerRect=null
|
|
36
|
+
*/
|
|
37
|
+
ownerRect: null,
|
|
38
|
+
/**
|
|
39
|
+
* Read only
|
|
40
|
+
* @member {Number|null} rows=null
|
|
41
|
+
*/
|
|
42
|
+
rows: null
|
|
43
|
+
}}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {Object} config
|
|
47
|
+
*/
|
|
48
|
+
constructor(config) {
|
|
49
|
+
super(config);
|
|
50
|
+
|
|
51
|
+
let me = this;
|
|
52
|
+
|
|
53
|
+
me.adjustCreateItem();
|
|
54
|
+
|
|
55
|
+
me.owner.store.on({
|
|
56
|
+
filter: me.onFilter,
|
|
57
|
+
sort : me.onSort,
|
|
58
|
+
scope : me
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
adjustCreateItem() {
|
|
66
|
+
let me = this,
|
|
67
|
+
owner = me.owner;
|
|
68
|
+
|
|
69
|
+
me.ownerCreateItem = owner.createItem.bind(owner);
|
|
70
|
+
owner.createItem = me.createItem.bind(owner, me);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {Neo.list.plugin.Animate} me
|
|
76
|
+
* @param {Object} record
|
|
77
|
+
* @param {Number} index
|
|
78
|
+
* @returns {Object}
|
|
79
|
+
*/
|
|
80
|
+
createItem(me, record, index) {
|
|
81
|
+
let item = me.ownerCreateItem(record, index),
|
|
82
|
+
itemHeight = me.itemHeight,
|
|
83
|
+
itemWidth = me.itemWidth,
|
|
84
|
+
margin = me.itemMargin,
|
|
85
|
+
style = item.style || {},
|
|
86
|
+
column, row, x, y;
|
|
87
|
+
|
|
88
|
+
if (!me.ownerRect) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
column = index % me.columns;
|
|
93
|
+
row = Math.floor(index / me.columns);
|
|
94
|
+
x = column * (margin + itemWidth) + margin;
|
|
95
|
+
y = row * (margin + itemHeight) + margin;
|
|
96
|
+
|
|
97
|
+
Object.assign(style, {
|
|
98
|
+
height : `${itemHeight}px`,
|
|
99
|
+
position : 'absolute',
|
|
100
|
+
transform: `translate(${x}px, ${y}px)`,
|
|
101
|
+
width : `${itemWidth}px`
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
item.style = style;
|
|
105
|
+
|
|
106
|
+
return item;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {Object} data
|
|
111
|
+
*/
|
|
112
|
+
onFilter(data) {
|
|
113
|
+
console.log('onFilter', data);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
onOwnerMounted() {
|
|
120
|
+
let me = this;
|
|
121
|
+
|
|
122
|
+
Neo.main.DomAccess.getBoundingClientRect({
|
|
123
|
+
id: me.owner.id
|
|
124
|
+
}).then(rect => {
|
|
125
|
+
Object.assign(me, {
|
|
126
|
+
columns : Math.floor(rect.width / me.itemWidth),
|
|
127
|
+
ownerRect: rect,
|
|
128
|
+
rows : Math.floor(rect.height / me.itemHeight)
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {Object} data
|
|
135
|
+
* @param {Object[]} data.items
|
|
136
|
+
* @param {Object[]} data.previousItems
|
|
137
|
+
* @param {Neo.data.Store} data.scope
|
|
138
|
+
*/
|
|
139
|
+
onSort(data) {
|
|
140
|
+
let me = this,
|
|
141
|
+
hasChange = false,
|
|
142
|
+
keyProperty = data.scope.keyProperty,
|
|
143
|
+
owner = me.owner,
|
|
144
|
+
newVdomCn = [],
|
|
145
|
+
vdom = owner.vdom,
|
|
146
|
+
vdomMap = vdom.cn.map(e => e.id),
|
|
147
|
+
fromIndex, itemId;
|
|
148
|
+
|
|
149
|
+
if (vdomMap.length > 0) {
|
|
150
|
+
data.items.forEach((item, index) => {
|
|
151
|
+
itemId = owner.getItemId(item[keyProperty]);
|
|
152
|
+
fromIndex = vdomMap.indexOf(itemId);
|
|
153
|
+
|
|
154
|
+
newVdomCn.push(vdom.cn[fromIndex]);
|
|
155
|
+
|
|
156
|
+
if (fromIndex !== index) {
|
|
157
|
+
hasChange = true;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
if (hasChange) {
|
|
162
|
+
owner.vdom.cn = newVdomCn;
|
|
163
|
+
|
|
164
|
+
owner.promiseVdomUpdate().then(() => {
|
|
165
|
+
// we need to ensure to get this call into the next animation frame
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
owner.createItems();
|
|
168
|
+
}, 50);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
Neo.applyClassConfig(Animate);
|
|
176
|
+
|
|
177
|
+
export {Animate as default};
|
package/src/model/Component.mjs
CHANGED
|
@@ -57,7 +57,6 @@ class Component extends Base {
|
|
|
57
57
|
}}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
60
|
* @param {Object} config
|
|
62
61
|
*/
|
|
63
62
|
constructor(config) {
|
|
@@ -135,7 +134,6 @@ class Component extends Base {
|
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
/**
|
|
138
|
-
*
|
|
139
137
|
* @param {Function} formatter
|
|
140
138
|
* @param {Object} [data=null] optionally pass this.getHierarchyData() for performance reasons
|
|
141
139
|
* @returns {String}
|
|
@@ -194,7 +192,6 @@ class Component extends Base {
|
|
|
194
192
|
}
|
|
195
193
|
|
|
196
194
|
/**
|
|
197
|
-
*
|
|
198
195
|
* @param {Neo.component.Base} component
|
|
199
196
|
*/
|
|
200
197
|
createBindings(component) {
|
|
@@ -210,7 +207,6 @@ class Component extends Base {
|
|
|
210
207
|
}
|
|
211
208
|
|
|
212
209
|
/**
|
|
213
|
-
*
|
|
214
210
|
* @param {Object} config
|
|
215
211
|
* @param {String} path
|
|
216
212
|
*/
|
|
@@ -238,7 +234,6 @@ class Component extends Base {
|
|
|
238
234
|
}
|
|
239
235
|
|
|
240
236
|
/**
|
|
241
|
-
*
|
|
242
237
|
* @param {String} key
|
|
243
238
|
* @param {String} path
|
|
244
239
|
* @param {Object} [root=this.data]
|
|
@@ -515,7 +510,6 @@ class Component extends Base {
|
|
|
515
510
|
}
|
|
516
511
|
|
|
517
512
|
/**
|
|
518
|
-
*
|
|
519
513
|
* @param {String} key
|
|
520
514
|
* @param {*} value
|
|
521
515
|
* @param {*} oldValue
|
|
@@ -543,9 +537,7 @@ class Component extends Base {
|
|
|
543
537
|
config[configField] = model.callFormatter(formatter, hierarchyData[model.id]);
|
|
544
538
|
});
|
|
545
539
|
|
|
546
|
-
|
|
547
|
-
component.set(config);
|
|
548
|
-
}
|
|
540
|
+
component?.set(config);
|
|
549
541
|
});
|
|
550
542
|
}
|
|
551
543
|
|
|
@@ -598,9 +590,7 @@ class Component extends Base {
|
|
|
598
590
|
delete binding[componentId];
|
|
599
591
|
});
|
|
600
592
|
|
|
601
|
-
|
|
602
|
-
parentModel.removeBindings(componentId);
|
|
603
|
-
}
|
|
593
|
+
parentModel?.removeBindings(componentId);
|
|
604
594
|
}
|
|
605
595
|
|
|
606
596
|
/**
|
|
@@ -608,9 +598,8 @@ class Component extends Base {
|
|
|
608
598
|
* @param {Neo.component.Base} component
|
|
609
599
|
* @param {String} configName
|
|
610
600
|
* @param {String} storeName
|
|
611
|
-
* @param {Neo.model.Component} [originModel=this] for internal usage only
|
|
612
601
|
*/
|
|
613
|
-
resolveStore(component, configName, storeName
|
|
602
|
+
resolveStore(component, configName, storeName) {
|
|
614
603
|
component[configName] = this.getStore(storeName);
|
|
615
604
|
}
|
|
616
605
|
|
package/src/worker/Manager.mjs
CHANGED
|
@@ -125,7 +125,12 @@ class Manager extends Base {
|
|
|
125
125
|
*/
|
|
126
126
|
broadcast(msg) {
|
|
127
127
|
Object.keys(this.workers).forEach(name => {
|
|
128
|
-
|
|
128
|
+
if (!(
|
|
129
|
+
name === 'canvas' && !NeoConfig.useCanvasWorker ||
|
|
130
|
+
name === 'vdom' && !NeoConfig.useVdomWorker
|
|
131
|
+
)) {
|
|
132
|
+
this.sendMessage(name, msg);
|
|
133
|
+
}
|
|
129
134
|
});
|
|
130
135
|
}
|
|
131
136
|
|