neo.mjs 8.15.0 → 8.16.0
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/apps/ServiceWorker.mjs
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.16.0",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"neo-jsdoc": "1.0.1",
|
61
61
|
"neo-jsdoc-x": "1.0.5",
|
62
62
|
"postcss": "^8.5.1",
|
63
|
-
"sass": "^1.
|
63
|
+
"sass": "^1.84.0",
|
64
64
|
"siesta-lite": "5.5.2",
|
65
65
|
"url": "^0.11.4",
|
66
66
|
"webpack": "^5.97.1",
|
package/src/DefaultConfig.mjs
CHANGED
@@ -262,12 +262,12 @@ const DefaultConfig = {
|
|
262
262
|
useVdomWorker: true,
|
263
263
|
/**
|
264
264
|
* buildScripts/injectPackageVersion.mjs will update this value
|
265
|
-
* @default '8.
|
265
|
+
* @default '8.16.0'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '8.
|
270
|
+
version: '8.16.0'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
@@ -82,6 +82,12 @@ class SortZone extends DragZone {
|
|
82
82
|
startIndex: -1
|
83
83
|
}
|
84
84
|
|
85
|
+
/**
|
86
|
+
* @member {Boolean} isOverDragging=false
|
87
|
+
* @protected
|
88
|
+
*/
|
89
|
+
isOverDragging = false
|
90
|
+
|
85
91
|
/**
|
86
92
|
* Override this method for class extensions (e.g. tab.header.Toolbar)
|
87
93
|
* @param {Number} fromIndex
|
@@ -150,52 +156,70 @@ class SortZone extends DragZone {
|
|
150
156
|
* @param {Object} data
|
151
157
|
*/
|
152
158
|
async onDragMove(data) {
|
153
|
-
//
|
159
|
+
// The method can trigger before we got the client rects from the main thread
|
154
160
|
if (!this.itemRects || this.isScrolling) {
|
155
161
|
return
|
156
162
|
}
|
157
163
|
|
158
164
|
let me = this,
|
159
|
-
moveFactor = 0.55, // we can not use 0.5, since items would jump back & forth
|
160
165
|
index = me.currentIndex,
|
161
166
|
{itemRects} = me,
|
162
167
|
maxItems = itemRects.length - 1,
|
163
168
|
reversed = me.reversedLayoutDirection,
|
164
|
-
delta,
|
169
|
+
delta, isOverDragging, isOverDraggingEnd, isOverDraggingStart, itemHeightOrWidth, moveFactor;
|
165
170
|
|
166
171
|
if (me.sortDirection === 'horizontal') {
|
167
|
-
delta
|
168
|
-
|
172
|
+
delta = data.clientX + me.scrollLeft - me.offsetX - itemRects[index].left;
|
173
|
+
isOverDraggingEnd = data.clientX > me.boundaryContainerRect.right;
|
174
|
+
isOverDraggingStart = data.clientX < me.boundaryContainerRect.left;
|
175
|
+
itemHeightOrWidth = 'width'
|
169
176
|
} else {
|
170
|
-
delta
|
171
|
-
|
177
|
+
delta = data.clientY + me.scrollTop - me.offsetY - itemRects[index].top;
|
178
|
+
isOverDraggingEnd = data.clientY > me.boundaryContainerRect.bottom;
|
179
|
+
isOverDraggingStart = data.clientY < me.boundaryContainerRect.top;
|
180
|
+
itemHeightOrWidth = 'height'
|
172
181
|
}
|
173
182
|
|
174
|
-
|
175
|
-
|
183
|
+
isOverDragging = isOverDraggingEnd || isOverDraggingStart;
|
184
|
+
moveFactor = isOverDragging ? 0.02 : 0.55; // We can not use 0.5, since items would jump back & forth
|
185
|
+
|
186
|
+
if (isOverDraggingStart) {
|
187
|
+
if (index > 0) {
|
176
188
|
me.currentIndex--;
|
189
|
+
await me.scrollToIndex();
|
190
|
+
me.switchItems(index, me.currentIndex)
|
191
|
+
}
|
192
|
+
}
|
177
193
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
194
|
+
else if (isOverDraggingEnd) {
|
195
|
+
if (index < maxItems) {
|
196
|
+
me.currentIndex++;
|
197
|
+
await me.scrollToIndex();
|
198
|
+
me.switchItems(index, me.currentIndex)
|
199
|
+
}
|
200
|
+
}
|
183
201
|
|
202
|
+
else if (index > 0 && (!reversed && delta < 0 || reversed && delta > 0)) {
|
203
|
+
if (Math.abs(delta) > itemRects[index - 1][itemHeightOrWidth] * moveFactor) {
|
204
|
+
me.currentIndex--;
|
184
205
|
me.switchItems(index, me.currentIndex)
|
185
206
|
}
|
186
207
|
}
|
187
208
|
|
188
209
|
else if (index < maxItems && (!reversed && delta > 0 || reversed && delta < 0)) {
|
189
|
-
if (Math.abs(delta) > itemRects[index + 1][
|
210
|
+
if (Math.abs(delta) > itemRects[index + 1][itemHeightOrWidth] * moveFactor) {
|
190
211
|
me.currentIndex++;
|
212
|
+
me.switchItems(index, me.currentIndex)
|
213
|
+
}
|
214
|
+
}
|
191
215
|
|
192
|
-
|
193
|
-
me.isScrolling = true;
|
194
|
-
await me.owner.scrollToIndex?.(me.currentIndex, itemRects[me.currentIndex]);
|
195
|
-
me.isScrolling = false
|
196
|
-
}
|
216
|
+
me.isOverDragging = isOverDragging && me.currentIndex !== 0 && me.currentIndex !== maxItems;
|
197
217
|
|
198
|
-
|
218
|
+
if (me.isOverDragging) {
|
219
|
+
await me.timeout(30); // wait for 1 frame
|
220
|
+
|
221
|
+
if (me.isOverDragging) {
|
222
|
+
await me.onDragMove(data)
|
199
223
|
}
|
200
224
|
}
|
201
225
|
}
|
@@ -227,7 +251,7 @@ class SortZone extends DragZone {
|
|
227
251
|
startIndex : index
|
228
252
|
});
|
229
253
|
|
230
|
-
await me.dragStart(data); //
|
254
|
+
await me.dragStart(data); // We do not want to trigger the super class call here
|
231
255
|
|
232
256
|
owner.items.forEach((item, index) => {
|
233
257
|
indexMap[index] = index;
|
@@ -244,7 +268,7 @@ class SortZone extends DragZone {
|
|
244
268
|
ownerStyle.height = `${itemRects[0].height}px`;
|
245
269
|
ownerStyle.width = `${itemRects[0].width}px`;
|
246
270
|
|
247
|
-
//
|
271
|
+
// The only reason we are adjusting the toolbar style is that there is no min height or width present.
|
248
272
|
// removing items from the layout could trigger a change in size.
|
249
273
|
owner.style = ownerStyle;
|
250
274
|
|
@@ -277,6 +301,17 @@ class SortZone extends DragZone {
|
|
277
301
|
}
|
278
302
|
}
|
279
303
|
|
304
|
+
/**
|
305
|
+
* @returns {Promise<void>}
|
306
|
+
*/
|
307
|
+
async scrollToIndex() {
|
308
|
+
let me = this;
|
309
|
+
|
310
|
+
me.isScrolling = true;
|
311
|
+
await me.owner.scrollToIndex?.(me.currentIndex, me.itemRects[me.currentIndex]);
|
312
|
+
me.isScrolling = false
|
313
|
+
}
|
314
|
+
|
280
315
|
/**
|
281
316
|
* @param {Number} index1
|
282
317
|
* @param {Number} index2
|