@kdcloudjs/table 1.2.2-canary.13 → 1.2.2-canary.14-hotfix
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/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +540 -331
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +4 -4
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/table/base/BlankComponent.d.ts +0 -1
- package/es/table/base/BlankComponent.js +16 -9
- package/es/table/pipeline/features/columnDrag.js +220 -242
- package/es/table/pipeline/features/columnResizeWidth.js +40 -5
- package/es/table/pipeline/features/rowDrag.js +169 -80
- package/es/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
- package/es/table/pipeline/features/utils/touchEventUtils.js +65 -0
- package/lib/table/base/BlankComponent.d.ts +0 -1
- package/lib/table/base/BlankComponent.js +15 -8
- package/lib/table/pipeline/features/columnDrag.js +220 -242
- package/lib/table/pipeline/features/columnResizeWidth.js +40 -5
- package/lib/table/pipeline/features/rowDrag.js +169 -80
- package/lib/table/pipeline/features/utils/touchEventUtils.d.ts +15 -0
- package/lib/table/pipeline/features/utils/touchEventUtils.js +76 -0
- package/package.json +2 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
|
-
import React, { useState, useImperativeHandle, forwardRef, memo } from 'react';
|
|
2
|
+
import React, { useState, useImperativeHandle, forwardRef, memo, useEffect } from 'react';
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import { Classes } from './styles';
|
|
5
5
|
var TopBlankComponent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
6
|
-
var
|
|
7
|
-
|
|
6
|
+
var heightFromProps = _ref.height;
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
setHeight(heightFromProps);
|
|
9
|
+
}, [heightFromProps]);
|
|
10
|
+
var _useState = useState(heightFromProps),
|
|
8
11
|
_useState2 = _slicedToArray(_useState, 2),
|
|
9
12
|
height = _useState2[0],
|
|
10
13
|
setHeight = _useState2[1];
|
|
@@ -18,6 +21,8 @@ var TopBlankComponent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
18
21
|
};
|
|
19
22
|
}, [height]);
|
|
20
23
|
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
key: "top-blank",
|
|
25
|
+
className: cx(Classes.virtualBlank, 'bottom'),
|
|
21
26
|
style: {
|
|
22
27
|
height: height
|
|
23
28
|
}
|
|
@@ -25,12 +30,14 @@ var TopBlankComponent = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
25
30
|
});
|
|
26
31
|
TopBlankComponent.displayName = 'TopBlank';
|
|
27
32
|
var BottomBlankComponent = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var _useState3 = useState(initialHeight),
|
|
33
|
+
var heightFromProps = _ref2.height;
|
|
34
|
+
var _useState3 = useState(heightFromProps),
|
|
31
35
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
36
|
height = _useState4[0],
|
|
33
37
|
setHeight = _useState4[1];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
setHeight(heightFromProps);
|
|
40
|
+
}, [heightFromProps]);
|
|
34
41
|
useImperativeHandle(ref, function () {
|
|
35
42
|
return {
|
|
36
43
|
updateHeight: function updateHeight(newHeight) {
|
|
@@ -45,7 +52,7 @@ var BottomBlankComponent = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
45
52
|
}
|
|
46
53
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
54
|
key: "bottom-blank",
|
|
48
|
-
className: cx(Classes.virtualBlank, 'bottom'
|
|
55
|
+
className: cx(Classes.virtualBlank, 'bottom'),
|
|
49
56
|
style: {
|
|
50
57
|
height: height
|
|
51
58
|
}
|
|
@@ -54,8 +61,8 @@ var BottomBlankComponent = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
54
61
|
BottomBlankComponent.displayName = 'BottomBlank';
|
|
55
62
|
// 使用 memo 优化,只有当 height 或 className 改变时才重新渲染
|
|
56
63
|
export var TopBlank = /*#__PURE__*/memo(TopBlankComponent, function (prevProps, nextProps) {
|
|
57
|
-
return prevProps.height === nextProps.height
|
|
64
|
+
return prevProps.height === nextProps.height;
|
|
58
65
|
});
|
|
59
66
|
export var BottomBlank = /*#__PURE__*/memo(BottomBlankComponent, function (prevProps, nextProps) {
|
|
60
|
-
return prevProps.height === nextProps.height
|
|
67
|
+
return prevProps.height === nextProps.height;
|
|
61
68
|
});
|
|
@@ -4,6 +4,7 @@ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray
|
|
|
4
4
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
5
5
|
import { makeRecursiveMapper, mergeCellProps, collectNodes, isLeafNode, isSelectColumn } from '../../utils';
|
|
6
6
|
import { FILL_COLUMN_CODE } from './autoFill';
|
|
7
|
+
import { getEventCoordinates, hasMovedEnough, addPointerEventListeners, removePointerEventListeners } from './utils/touchEventUtils';
|
|
7
8
|
var stateKey = 'columnDrag';
|
|
8
9
|
var SCROLL_SIZE = 30;
|
|
9
10
|
function disableSelect(event) {
|
|
@@ -61,251 +62,237 @@ export function columnDrag() {
|
|
|
61
62
|
style: style
|
|
62
63
|
});
|
|
63
64
|
},
|
|
64
|
-
headerCellProps: mergeCellProps(col.headerCellProps, {
|
|
65
|
-
onMouseDown:
|
|
65
|
+
headerCellProps: mergeCellProps(col.headerCellProps, _extends(_extends({}, isLeaf && path.length === 1 ? {
|
|
66
|
+
onMouseDown: function onMouseDown(e) {
|
|
66
67
|
if (e.button !== 0 || !e.currentTarget.contains(e.target)) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
lock: lock
|
|
176
|
-
})) {
|
|
177
|
-
cloumnsTranslateData[code] += _adjustTranslation(optionColumn.width);
|
|
178
|
-
if (isLeafNode(columns[index])) {
|
|
179
|
-
cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(width);
|
|
180
|
-
} else {
|
|
181
|
-
cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(getColumnWidth(columns[index]));
|
|
182
|
-
moveAllChildren(children, cloumnsTranslateData, _adjustTranslation(optionColumn.width));
|
|
183
|
-
}
|
|
184
|
-
columnMoved = true;
|
|
185
|
-
}
|
|
186
|
-
index++;
|
|
187
|
-
}
|
|
188
|
-
} else if (startIndex < replaceIndex) {
|
|
189
|
-
// 右移
|
|
190
|
-
while (startIndex < index) {
|
|
191
|
-
var _columns$index2 = columns[index],
|
|
192
|
-
_code = _columns$index2.code,
|
|
193
|
-
_lock = _columns$index2.lock,
|
|
194
|
-
_width = _columns$index2.width,
|
|
195
|
-
_children = _columns$index2.children;
|
|
196
|
-
if (enableMove({
|
|
197
|
-
code: _code,
|
|
198
|
-
lock: _lock
|
|
199
|
-
})) {
|
|
200
|
-
cloumnsTranslateData[_code] -= _adjustTranslation(optionColumn.width);
|
|
201
|
-
if (isLeafNode(columns[index])) {
|
|
202
|
-
cloumnsTranslateData[optionColumn.code] += _adjustTranslation(_width);
|
|
203
|
-
} else {
|
|
204
|
-
cloumnsTranslateData[optionColumn.code] += _adjustTranslation(getColumnWidth(columns[index]));
|
|
205
|
-
moveAllChildren(_children, cloumnsTranslateData, _adjustTranslation(optionColumn.width), true);
|
|
206
|
-
}
|
|
207
|
-
columnMoved = true;
|
|
208
|
-
}
|
|
209
|
-
index--;
|
|
70
|
+
handlePointerDown(e.nativeEvent, false, e.currentTarget);
|
|
71
|
+
},
|
|
72
|
+
onTouchStart: function onTouchStart(e) {
|
|
73
|
+
// 阻止触摸事件的默认行为
|
|
74
|
+
if (e.cancelable) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
}
|
|
77
|
+
handlePointerDown(e.nativeEvent, true, e.currentTarget);
|
|
78
|
+
}
|
|
79
|
+
} : {}), {
|
|
80
|
+
style: style
|
|
81
|
+
}))
|
|
82
|
+
});
|
|
83
|
+
// 统一的拖拽处理函数
|
|
84
|
+
function handlePointerDown(startEvent, isTouch, currentTarget) {
|
|
85
|
+
var _a;
|
|
86
|
+
window.addEventListener('selectstart', disableSelect);
|
|
87
|
+
var columnMoved = false;
|
|
88
|
+
var columns = pipeline.getColumns();
|
|
89
|
+
var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
|
|
90
|
+
cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
|
|
91
|
+
var cloumnsSortData = {};
|
|
92
|
+
columns.forEach(function (item, index) {
|
|
93
|
+
cloumnsSortData[item.code] = index;
|
|
94
|
+
});
|
|
95
|
+
var rect = (_a = currentTarget.parentElement) === null || _a === void 0 ? void 0 : _a.getClientRects()[0];
|
|
96
|
+
if (!rect) return;
|
|
97
|
+
var startX = direction === 'rtl' ? rect.right : rect.left;
|
|
98
|
+
var startCoordinates = getEventCoordinates(startEvent);
|
|
99
|
+
var mouseDownClientX = startCoordinates.clientX;
|
|
100
|
+
var mouseDownClientY = startCoordinates.clientY;
|
|
101
|
+
var moveData = [];
|
|
102
|
+
var allColumns = collectNodes(columns);
|
|
103
|
+
var tableBodyClientRect = tableBody.getBoundingClientRect();
|
|
104
|
+
var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
|
|
105
|
+
var updateScrollPosition = function updateScrollPosition(client) {
|
|
106
|
+
var clientX = client.clientX;
|
|
107
|
+
var left = tableBodyClientRect.left,
|
|
108
|
+
width = tableBodyClientRect.width;
|
|
109
|
+
if (clientX + SCROLL_SIZE >= left + width) {
|
|
110
|
+
pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
|
|
111
|
+
}
|
|
112
|
+
if (clientX - SCROLL_SIZE <= left) {
|
|
113
|
+
pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function handlePointerMove(e) {
|
|
117
|
+
// 触摸事件需要阻止默认行为,防止页面滚动
|
|
118
|
+
if (isTouch && e.cancelable) {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
}
|
|
121
|
+
var coordinates = getEventCoordinates(e);
|
|
122
|
+
var client = {
|
|
123
|
+
clientX: coordinates.clientX,
|
|
124
|
+
clientY: coordinates.clientY
|
|
125
|
+
};
|
|
126
|
+
var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
|
|
127
|
+
var startPosition = startX - scrollDistance; // 表头最左边起点
|
|
128
|
+
var offsetDistance = direction === 'rtl' ? startPosition - coordinates.clientX : coordinates.clientX - startPosition;
|
|
129
|
+
updateScrollPosition(client);
|
|
130
|
+
if (offsetDistance < 20) {
|
|
131
|
+
return;
|
|
132
|
+
} else {
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
}
|
|
135
|
+
document.body.style.userSelect = 'none';
|
|
136
|
+
currentTarget.style.cursor = 'move';
|
|
137
|
+
// 重置位置信息
|
|
138
|
+
cloumnsTranslateData = {};
|
|
139
|
+
allColumns.forEach(function (item) {
|
|
140
|
+
cloumnsTranslateData[item.code] = 0;
|
|
141
|
+
});
|
|
142
|
+
// 计算平移位置
|
|
143
|
+
var replaceIndex = 0;
|
|
144
|
+
var totalWitdth = getColumnWidth(columns[replaceIndex]);
|
|
145
|
+
while (totalWitdth < offsetDistance && replaceIndex < columns.length - 1) {
|
|
146
|
+
replaceIndex++;
|
|
147
|
+
totalWitdth += getColumnWidth(columns[replaceIndex]);
|
|
148
|
+
}
|
|
149
|
+
// 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
|
|
150
|
+
var startIndex;
|
|
151
|
+
columns.forEach(function (column, index) {
|
|
152
|
+
if (column.code === col.code) {
|
|
153
|
+
startIndex = index;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
var optionColumn = columns[startIndex];
|
|
157
|
+
var index = replaceIndex;
|
|
158
|
+
if (startIndex > replaceIndex) {
|
|
159
|
+
// 左移
|
|
160
|
+
while (index < startIndex) {
|
|
161
|
+
var _columns$index = columns[index],
|
|
162
|
+
code = _columns$index.code,
|
|
163
|
+
lock = _columns$index.lock,
|
|
164
|
+
width = _columns$index.width,
|
|
165
|
+
children = _columns$index.children;
|
|
166
|
+
if (enableMove({
|
|
167
|
+
code: code,
|
|
168
|
+
lock: lock
|
|
169
|
+
})) {
|
|
170
|
+
cloumnsTranslateData[code] += _adjustTranslation(optionColumn.width);
|
|
171
|
+
if (isLeafNode(columns[index])) {
|
|
172
|
+
cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(width);
|
|
173
|
+
} else {
|
|
174
|
+
cloumnsTranslateData[optionColumn.code] -= _adjustTranslation(getColumnWidth(columns[index]));
|
|
175
|
+
moveAllChildren(children, cloumnsTranslateData, _adjustTranslation(optionColumn.width));
|
|
210
176
|
}
|
|
177
|
+
columnMoved = true;
|
|
211
178
|
}
|
|
212
|
-
|
|
213
|
-
pipeline.setStateAtKey(stateKey, {
|
|
214
|
-
cloumnsTranslateData: cloumnsTranslateData
|
|
215
|
-
});
|
|
216
|
-
moveData = [startIndex, replaceIndex];
|
|
217
|
-
});
|
|
179
|
+
index++;
|
|
218
180
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
181
|
+
} else if (startIndex < replaceIndex) {
|
|
182
|
+
// 右移
|
|
183
|
+
while (startIndex < index) {
|
|
184
|
+
var _columns$index2 = columns[index],
|
|
185
|
+
_code = _columns$index2.code,
|
|
186
|
+
_lock = _columns$index2.lock,
|
|
187
|
+
_width = _columns$index2.width,
|
|
188
|
+
_children = _columns$index2.children;
|
|
189
|
+
if (enableMove({
|
|
190
|
+
code: _code,
|
|
191
|
+
lock: _lock
|
|
192
|
+
})) {
|
|
193
|
+
cloumnsTranslateData[_code] -= _adjustTranslation(optionColumn.width);
|
|
194
|
+
if (isLeafNode(columns[index])) {
|
|
195
|
+
cloumnsTranslateData[optionColumn.code] += _adjustTranslation(_width);
|
|
196
|
+
} else {
|
|
197
|
+
cloumnsTranslateData[optionColumn.code] += _adjustTranslation(getColumnWidth(columns[index]));
|
|
198
|
+
moveAllChildren(_children, cloumnsTranslateData, _adjustTranslation(optionColumn.width), true);
|
|
199
|
+
}
|
|
200
|
+
columnMoved = true;
|
|
226
201
|
}
|
|
202
|
+
index--;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
window.requestAnimationFrame(function () {
|
|
206
|
+
pipeline.setStateAtKey(stateKey, {
|
|
207
|
+
cloumnsTranslateData: cloumnsTranslateData
|
|
208
|
+
});
|
|
209
|
+
moveData = [startIndex, replaceIndex];
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function handlePointerUp(e) {
|
|
213
|
+
removePointerEventListeners(document.body, {
|
|
214
|
+
onPointerMove: handlePointerMove,
|
|
215
|
+
onPointerUp: handlePointerUp
|
|
216
|
+
}, isTouch);
|
|
217
|
+
window.removeEventListener('selectstart', disableSelect);
|
|
218
|
+
var endCoordinates = getEventCoordinates(e);
|
|
219
|
+
if (hasMovedEnough(mouseDownClientX, mouseDownClientY, endCoordinates.clientX, endCoordinates.clientY)) {
|
|
220
|
+
e.stopPropagation(); // 存在移动就阻止冒泡
|
|
221
|
+
currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
|
|
222
|
+
}
|
|
227
223
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
lock = _columns$index3.lock;
|
|
252
|
-
if (enableMove({
|
|
253
|
-
code: code,
|
|
254
|
-
lock: lock
|
|
255
|
-
})) {
|
|
256
|
-
cloumnsSortData[code] += 1;
|
|
257
|
-
cloumnsSortData[optionColumn.code] -= 1;
|
|
258
|
-
columnMoved = true;
|
|
259
|
-
}
|
|
260
|
-
index++;
|
|
261
|
-
}
|
|
262
|
-
} else if (startIndex < replaceIndex) {
|
|
263
|
-
// 右移
|
|
264
|
-
while (index > startIndex) {
|
|
265
|
-
var _columns$index4 = columns[index],
|
|
266
|
-
_code2 = _columns$index4.code,
|
|
267
|
-
_lock2 = _columns$index4.lock;
|
|
268
|
-
if (enableMove({
|
|
269
|
-
code: _code2,
|
|
270
|
-
lock: _lock2
|
|
271
|
-
})) {
|
|
272
|
-
cloumnsSortData[_code2] -= 1;
|
|
273
|
-
cloumnsSortData[optionColumn.code] += 1;
|
|
274
|
-
columnMoved = true;
|
|
275
|
-
}
|
|
276
|
-
index--;
|
|
277
|
-
}
|
|
224
|
+
window.requestAnimationFrame(function () {
|
|
225
|
+
// 取消阻止列头点击事件
|
|
226
|
+
currentTarget.removeEventListener('click', stopClickPropagation);
|
|
227
|
+
currentTarget = null;
|
|
228
|
+
var _moveData = moveData,
|
|
229
|
+
_moveData2 = _slicedToArray(_moveData, 2),
|
|
230
|
+
startIndex = _moveData2[0],
|
|
231
|
+
replaceIndex = _moveData2[1];
|
|
232
|
+
var optionColumn = columns[startIndex];
|
|
233
|
+
var index = replaceIndex;
|
|
234
|
+
if (startIndex > replaceIndex) {
|
|
235
|
+
// 左移
|
|
236
|
+
while (index < startIndex) {
|
|
237
|
+
var _columns$index3 = columns[index],
|
|
238
|
+
code = _columns$index3.code,
|
|
239
|
+
lock = _columns$index3.lock;
|
|
240
|
+
if (enableMove({
|
|
241
|
+
code: code,
|
|
242
|
+
lock: lock
|
|
243
|
+
})) {
|
|
244
|
+
cloumnsSortData[code] += 1;
|
|
245
|
+
cloumnsSortData[optionColumn.code] -= 1;
|
|
246
|
+
columnMoved = true;
|
|
278
247
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
248
|
+
index++;
|
|
249
|
+
}
|
|
250
|
+
} else if (startIndex < replaceIndex) {
|
|
251
|
+
// 右移
|
|
252
|
+
while (index > startIndex) {
|
|
253
|
+
var _columns$index4 = columns[index],
|
|
254
|
+
_code2 = _columns$index4.code,
|
|
255
|
+
_lock2 = _columns$index4.lock;
|
|
256
|
+
if (enableMove({
|
|
257
|
+
code: _code2,
|
|
258
|
+
lock: _lock2
|
|
259
|
+
})) {
|
|
260
|
+
cloumnsSortData[_code2] -= 1;
|
|
261
|
+
cloumnsSortData[optionColumn.code] += 1;
|
|
262
|
+
columnMoved = true;
|
|
292
263
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
264
|
+
index--;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
var onColumnDragStopped = opts.onColumnDragStopped;
|
|
268
|
+
// 拖拽结束返回列顺序
|
|
269
|
+
if (onColumnDragStopped) {
|
|
270
|
+
var _context;
|
|
271
|
+
var isRowDragColumn = function isRowDragColumn(code) {
|
|
272
|
+
var rowDragColumnKey = pipeline.getFeatureOptions('rowDragColumnKey');
|
|
273
|
+
return code === rowDragColumnKey;
|
|
274
|
+
};
|
|
275
|
+
var newColumns = _filterInstanceProperty(_context = sortColumns(columns, cloumnsSortData)).call(_context, function (column) {
|
|
276
|
+
return column.code !== FILL_COLUMN_CODE && !isRowDragColumn(column.code) && !isSelectColumn(column);
|
|
296
277
|
});
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
currentTarget.style.cursor = '';
|
|
278
|
+
// TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
|
|
279
|
+
onColumnDragStopped(columnMoved, newColumns);
|
|
300
280
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
style
|
|
307
|
-
|
|
308
|
-
|
|
281
|
+
pipeline.setStateAtKey(stateKey, {
|
|
282
|
+
cloumnsTranslateData: null
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
document.body.style.userSelect = '';
|
|
286
|
+
currentTarget.style.opacity = '';
|
|
287
|
+
currentTarget.style.cursor = '';
|
|
288
|
+
}
|
|
289
|
+
var onColumnDragStart = opts.onColumnDragStart;
|
|
290
|
+
onColumnDragStart && onColumnDragStart(col);
|
|
291
|
+
addPointerEventListeners(document.body, {
|
|
292
|
+
onPointerMove: handlePointerMove,
|
|
293
|
+
onPointerUp: handlePointerUp
|
|
294
|
+
}, isTouch);
|
|
295
|
+
}
|
|
309
296
|
}));
|
|
310
297
|
};
|
|
311
298
|
}
|
|
@@ -333,13 +320,4 @@ function moveAllChildren(cols, cloumnsTranslateData, width, isMinus) {
|
|
|
333
320
|
moveAllChildren(children, cloumnsTranslateData, width);
|
|
334
321
|
}
|
|
335
322
|
});
|
|
336
|
-
}
|
|
337
|
-
function _isMoveWhenClicking(mouseDownClientX, mouseDownClientY, mouseUpClientX, mouseUpClientY) {
|
|
338
|
-
var xDiff = mouseUpClientX - mouseDownClientX;
|
|
339
|
-
var yDiff = mouseUpClientY - mouseDownClientY;
|
|
340
|
-
// 鼠标点按和松开的偏移量大于5px,认为存在移动
|
|
341
|
-
if (Math.sqrt(xDiff * xDiff + yDiff * yDiff) > 5) {
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
return false;
|
|
345
323
|
}
|