@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.
@@ -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 initialHeight = _ref.height;
19
- var _useState = (0, _react.useState)(initialHeight),
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 initialHeight = _ref2.height,
41
- className = _ref2.className;
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', className),
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 && prevProps.className === nextProps.className;
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 && prevProps.className === nextProps.className;
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: !isLeaf || path.length > 1 ? undefined : function (e) {
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
- window.addEventListener('selectstart', disableSelect);
77
- // const cx = e.clientX
78
- // const width = col.width
79
- // const a = startIndex
80
- // const b = endIndex
81
- // const newColumnDragData = [...columnDragData]
82
- // let newColumn = [...columns]
83
- // let newStartIndex = startIndex
84
- // let endIdx = endIndex
85
- var columnMoved = false;
86
- var columns = pipeline.getColumns();
87
- var _pipeline$getStateAtK2 = pipeline.getStateAtKey(stateKey, {}),
88
- cloumnsTranslateData = _pipeline$getStateAtK2.cloumnsTranslateData;
89
- var cloumnsSortData = {};
90
- columns.forEach(function (item, index) {
91
- cloumnsSortData[item.code] = index;
92
- });
93
- var currentTarget = e.currentTarget;
94
- var rect = e.currentTarget.parentElement.getClientRects()[0];
95
- var startX = direction === 'rtl' ? rect.right : rect.left;
96
- var mouseDownClientX = e.clientX;
97
- var mouseDownClientY = e.clientY;
98
- var moveData = [];
99
- var allColumns = (0, _utils.collectNodes)(columns);
100
- var tableBodyClientRect = tableBody.getBoundingClientRect();
101
- var startScrollLeft = pipeline.ref.current.domHelper.virtual.scrollLeft;
102
- var updateScrollPosition = function updateScrollPosition(client) {
103
- var clientX = client.clientX;
104
- var left = tableBodyClientRect.left,
105
- width = tableBodyClientRect.width;
106
- if (clientX + SCROLL_SIZE >= left + width) {
107
- pipeline.ref.current.domHelper.virtual.scrollLeft += SCROLL_SIZE;
108
- }
109
- if (clientX - SCROLL_SIZE <= left) {
110
- pipeline.ref.current.domHelper.virtual.scrollLeft -= SCROLL_SIZE;
111
- }
112
- };
113
- function handleMouseMove(e) {
114
- var client = {
115
- clientX: e.clientX,
116
- clientY: e.clientY
117
- };
118
- var scrollDistance = pipeline.ref.current.domHelper.virtual.scrollLeft - startScrollLeft;
119
- var startPosition = startX - scrollDistance; // 表头最左边起点
120
- var offsetDistance = direction === 'rtl' ? startPosition - e.clientX : e.clientX - startPosition;
121
- updateScrollPosition(client);
122
- if (offsetDistance < 20) {
123
- return;
124
- } else {
125
- e.stopPropagation();
126
- }
127
- document.body.style.userSelect = 'none';
128
- currentTarget.style.cursor = 'move';
129
- // 循环计算每一个的位置
130
- // if (startIndex !== replaceIndex) {
131
- // const optionColumn = columns[startIndex]
132
- // const move = startIndex > replaceIndex ? 1 : -1
133
- // let index = Math.min(startIndex, replaceIndex)
134
- // while (index < Math.max(startIndex, replaceIndex)) {
135
- // const code = columns[index].code
136
- // cloumnsTranslateData[code] += move * optionColumn.width
137
- // cloumnsTranslateData[optionColumn.code] -= move * optionColumn.width
138
- // index += move
139
- // }
140
- // }
141
- // const opColumn = columns[startIndex]
142
- // let index = Math.min(startIndex, replaceIndex)
143
- // while (index <= Math.max(startIndex, replaceIndex)) {
144
- // const code = columns[index].code
145
- // if (index !== startIndex && index !== replaceIndex) {
146
- // cloumnsTranslateData[code] += opColumn.width * (index > startIndex ? -1 : 1)
147
- // cloumnsTranslateData[opColumn.code] += columns[index].width * (index < startIndex ? -1 : 1)
148
- // }
149
- // index++
150
- // }
151
- // 重置位置信息
152
- cloumnsTranslateData = {};
153
- allColumns.forEach(function (item) {
154
- cloumnsTranslateData[item.code] = 0;
155
- });
156
- // 计算平移位置
157
- var replaceIndex = 0;
158
- var totalWitdth = getColumnWidth(columns[replaceIndex]);
159
- while (totalWitdth < offsetDistance && replaceIndex < columns.length - 1) {
160
- replaceIndex++;
161
- totalWitdth += getColumnWidth(columns[replaceIndex]);
162
- }
163
- // 需要取最新startIndex, 不能直接用makeRecursiveMapper提供的startIndex(因为map时还没添加选择列、充满列等后面use添加的列)
164
- var startIndex;
165
- columns.forEach(function (column, index) {
166
- if (column.code === col.code) {
167
- startIndex = index;
168
- }
169
- });
170
- var optionColumn = columns[startIndex];
171
- var index = replaceIndex;
172
- if (startIndex > replaceIndex) {
173
- // 左移
174
- while (index < startIndex) {
175
- var _columns$index = columns[index],
176
- code = _columns$index.code,
177
- lock = _columns$index.lock,
178
- width = _columns$index.width,
179
- children = _columns$index.children;
180
- if (enableMove({
181
- code: code,
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
- window.requestAnimationFrame(function () {
220
- pipeline.setStateAtKey(stateKey, {
221
- cloumnsTranslateData: cloumnsTranslateData
222
- });
223
- moveData = [startIndex, replaceIndex];
224
- });
186
+ index++;
225
187
  }
226
- function handleMouseUp(e) {
227
- document.body.removeEventListener('mousemove', handleMouseMove);
228
- document.body.removeEventListener('mouseup', handleMouseUp);
229
- window.removeEventListener('selectstart', disableSelect);
230
- if (_isMoveWhenClicking(mouseDownClientX, mouseDownClientY, e.clientX, e.clientY)) {
231
- e.stopPropagation(); // 存在移动就阻止冒泡
232
- currentTarget.addEventListener('click', stopClickPropagation); // 阻止列头点击事件,防止拖动后触发列头过滤事件
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
- window.requestAnimationFrame(function () {
236
- // 取消阻止列头点击事件
237
- currentTarget.removeEventListener('click', stopClickPropagation);
238
- currentTarget = null;
239
- var _moveData = moveData,
240
- _moveData2 = (0, _slicedToArray2.default)(_moveData, 2),
241
- startIndex = _moveData2[0],
242
- replaceIndex = _moveData2[1];
243
- var optionColumn = columns[startIndex];
244
- // const move = startIndex > replaceIndex ? 1 : -1
245
- // let index = Math.min(startIndex, replaceIndex)
246
- // while (index < Math.max(startIndex, replaceIndex) && index > 0) {
247
- // const code = columns[index].code
248
- // cloumnsSortData[optionColumn.code] -= move
249
- // cloumnsSortData[code] += move
250
- // index += move
251
- // }
252
- var index = replaceIndex;
253
- if (startIndex > replaceIndex) {
254
- // 左移
255
- while (index < startIndex) {
256
- var _columns$index3 = columns[index],
257
- code = _columns$index3.code,
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
- var onColumnDragStopped = opts.onColumnDragStopped;
287
- // 拖拽结束返回列顺序
288
- if (onColumnDragStopped) {
289
- var _context;
290
- var isRowDragColumn = function isRowDragColumn(code) {
291
- var rowDragColumnKey = pipeline.getFeatureOptions('rowDragColumnKey');
292
- return code === rowDragColumnKey;
293
- };
294
- var newColumns = (0, _filter.default)(_context = sortColumns(columns, cloumnsSortData)).call(_context, function (column) {
295
- return column.code !== _autoFill.FILL_COLUMN_CODE && !isRowDragColumn(column.code) && !(0, _utils.isSelectColumn)(column);
296
- });
297
- // TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
298
- onColumnDragStopped(columnMoved, newColumns);
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
- pipeline.setStateAtKey(stateKey, {
301
- cloumnsTranslateData: null
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
- document.body.style.userSelect = '';
305
- currentTarget.style.opacity = '';
306
- currentTarget.style.cursor = '';
285
+ // TODO drag需要在resize之后use,否则这里返回的列对应的宽度不是拖拽后的
286
+ onColumnDragStopped(columnMoved, newColumns);
307
287
  }
308
- var onColumnDragStart = opts.onColumnDragStart;
309
- onColumnDragStart && onColumnDragStart(col);
310
- document.body.addEventListener('mousemove', handleMouseMove);
311
- document.body.addEventListener('mouseup', handleMouseUp);
312
- },
313
- style: 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
  }