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