@vaadin/vaadin-grid 5.9.6 → 5.9.7
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/package.json
CHANGED
|
@@ -36,7 +36,12 @@ interface ColumnReorderingMixin {
|
|
|
36
36
|
*/
|
|
37
37
|
columnReorderingAllowed: boolean;
|
|
38
38
|
ready(): void;
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the columns (or column groups) on the specified header level in visual order.
|
|
42
|
+
* By default, the bottom level is used.
|
|
43
|
+
*/
|
|
44
|
+
_getColumnsInOrder(headerLevel: any): GridColumnElement[];
|
|
40
45
|
_cellFromPoint(x: number, y: number): HTMLElement|null|undefined;
|
|
41
46
|
_updateGhostPosition(eventClientX: number, eventClientY: number): void;
|
|
42
47
|
_getInnerText(e: Element): string;
|
|
@@ -165,7 +165,23 @@ export const ColumnReorderingMixin = superClass => class ColumnReorderingMixin e
|
|
|
165
165
|
const targetColumn = this._getTargetColumn(targetCell, this._draggedColumn);
|
|
166
166
|
if (this._isSwapAllowed(this._draggedColumn, targetColumn) &&
|
|
167
167
|
this._isSwappableByPosition(targetColumn, e.detail.x)) {
|
|
168
|
-
|
|
168
|
+
// Get the header level of the target column (and the dragged column)
|
|
169
|
+
const columnTreeLevel = this.__getColumnTreeLevel(targetColumn);
|
|
170
|
+
// Get the columns on that level in visual order
|
|
171
|
+
const levelColumnsInOrder = this._getColumnsInOrder(columnTreeLevel);
|
|
172
|
+
|
|
173
|
+
// Index of the column being dragged
|
|
174
|
+
const startIndex = levelColumnsInOrder.indexOf(this._draggedColumn);
|
|
175
|
+
// Index of the column being dragged over
|
|
176
|
+
const endIndex = levelColumnsInOrder.indexOf(targetColumn);
|
|
177
|
+
|
|
178
|
+
// Direction of iteration
|
|
179
|
+
const direction = startIndex < endIndex ? 1 : -1;
|
|
180
|
+
|
|
181
|
+
// Iteratively swap all the columns from the dragged column to the target column
|
|
182
|
+
for (let i = startIndex; i !== endIndex; i += direction) {
|
|
183
|
+
this._swapColumnOrders(this._draggedColumn, levelColumnsInOrder[i + direction]);
|
|
184
|
+
}
|
|
169
185
|
}
|
|
170
186
|
|
|
171
187
|
this._updateGhostPosition(e.detail.x, this._touchDevice ? e.detail.y - 50 : e.detail.y);
|
|
@@ -192,13 +208,17 @@ export const ColumnReorderingMixin = superClass => class ColumnReorderingMixin e
|
|
|
192
208
|
}
|
|
193
209
|
|
|
194
210
|
/**
|
|
211
|
+
* Returns the columns (or column groups) on the specified header level in visual order.
|
|
212
|
+
* By default, the bottom level is used.
|
|
213
|
+
*
|
|
195
214
|
* @return {!Array<!GridColumnElement>}
|
|
196
215
|
* @protected
|
|
197
216
|
*/
|
|
198
|
-
_getColumnsInOrder() {
|
|
199
|
-
|
|
200
|
-
.
|
|
201
|
-
|
|
217
|
+
_getColumnsInOrder(headerLevel) {
|
|
218
|
+
if (!headerLevel && headerLevel !== 0) {
|
|
219
|
+
headerLevel = this._columnTree.length - 1;
|
|
220
|
+
}
|
|
221
|
+
return this._columnTree[headerLevel].filter((c) => !c.hidden).sort((b, a) => b._order - a._order);
|
|
202
222
|
}
|
|
203
223
|
|
|
204
224
|
/**
|
|
@@ -401,6 +421,16 @@ export const ColumnReorderingMixin = superClass => class ColumnReorderingMixin e
|
|
|
401
421
|
}
|
|
402
422
|
}
|
|
403
423
|
|
|
424
|
+
/** @private */
|
|
425
|
+
__getColumnTreeLevel(column) {
|
|
426
|
+
for (let level = 0; level < this._columnTree.length; level++) {
|
|
427
|
+
if (this._columnTree[level].indexOf(column) >= 0) {
|
|
428
|
+
return level;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return -1;
|
|
432
|
+
}
|
|
433
|
+
|
|
404
434
|
/**
|
|
405
435
|
* Fired when the columns in the grid are reordered.
|
|
406
436
|
*
|
|
@@ -277,6 +277,27 @@ class GridScrollerElement extends PolymerIronList {
|
|
|
277
277
|
_scrollHandler() {
|
|
278
278
|
const delta = this.$.table.scrollTop - this._scrollPosition;
|
|
279
279
|
this._accessIronListAPI(super._scrollHandler);
|
|
280
|
+
|
|
281
|
+
if (this._physicalCount !== 0) {
|
|
282
|
+
const isScrollingDown = delta >= 0;
|
|
283
|
+
const reusables = this._getReusables(!isScrollingDown);
|
|
284
|
+
|
|
285
|
+
if (reusables.indexes.length) {
|
|
286
|
+
// After running super._scrollHandler, fix internal properties to workaround an iron-list issue.
|
|
287
|
+
// See https://github.com/vaadin/web-components/issues/1691
|
|
288
|
+
this._physicalTop = reusables.physicalTop;
|
|
289
|
+
|
|
290
|
+
if (isScrollingDown) {
|
|
291
|
+
this._virtualStart -= reusables.indexes.length;
|
|
292
|
+
this._physicalStart -= reusables.indexes.length;
|
|
293
|
+
} else {
|
|
294
|
+
this._virtualStart += reusables.indexes.length;
|
|
295
|
+
this._physicalStart += reusables.indexes.length;
|
|
296
|
+
}
|
|
297
|
+
this._update(reusables.indexes, !isScrollingDown);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
280
301
|
const oldOffset = this._vidxOffset;
|
|
281
302
|
if (this._accessIronListAPI(() => this._maxScrollTop) && this._virtualCount < this._effectiveSize) {
|
|
282
303
|
this._adjustVirtualIndexOffset(delta);
|