@kdcloudjs/table 1.2.1-canary.4 → 1.2.1-canary.5

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.
@@ -3,7 +3,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
3
3
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
4
4
  import React from 'react';
5
5
  import { fromEvent } from 'rxjs';
6
- import { map, takeUntil } from 'rxjs/operators';
6
+ import { map, takeUntil, filter } from 'rxjs/operators';
7
7
  import cx from 'classnames';
8
8
  import { Classes } from '../../base/styles';
9
9
  export var ROW_DRAG_COLUMN_CODE = '$_row_drag_column_&';
@@ -60,13 +60,13 @@ export function rowDrag(opt) {
60
60
  pipeline.setStateAtKey(rowDragKey, event);
61
61
  };
62
62
 
63
- var handleDragEnd = function handleDragEnd(event, isOutOfRange) {
63
+ var handleDragEnd = function handleDragEnd(event, isValid) {
64
64
  var _a;
65
65
 
66
66
  artTable.classList.remove(cx(Classes.rowDragging));
67
67
  pipeline.setStateAtKey(rowDragKey, event); // 超出拖拽范围不触发dragend事件
68
68
 
69
- if (!isOutOfRange) {
69
+ if (isValid) {
70
70
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, event);
71
71
  }
72
72
  };
@@ -111,6 +111,7 @@ export function rowDrag(opt) {
111
111
 
112
112
  var dragPosition = 'bottom';
113
113
  var isOutOfRange = false;
114
+ var isValidDrag = false;
114
115
  var dragStartEvent = getDragEvent(startRowInfo, endRowInfo, {
115
116
  isFinished: false,
116
117
  dragPosition: 'bottom'
@@ -119,6 +120,7 @@ export function rowDrag(opt) {
119
120
  var tableWidth = tableBody.clientWidth;
120
121
  var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
121
122
 
123
+ var mouseDownClientY = mouseDownEvent.clientY;
122
124
  var startOffset = mouseDownEvent.clientY - startRowRects.top;
123
125
  var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
124
126
 
@@ -145,7 +147,15 @@ export function rowDrag(opt) {
145
147
  };
146
148
 
147
149
  document.addEventListener('scroll', scrollCallback, true);
148
- var rowDrag$ = mousemove$.pipe(map(function (mouseMoveEvent) {
150
+ var rowDrag$ = mousemove$.pipe(filter(function (mouseMoveEvent) {
151
+ var mouseMoveClientY = mouseMoveEvent.clientY; // 上下移动偏移量大于5才是有效的拖拽
152
+
153
+ if (Math.abs(mouseMoveClientY - mouseDownClientY) > 5) {
154
+ isValidDrag = true;
155
+ }
156
+
157
+ return isValidDrag;
158
+ }), map(function (mouseMoveEvent) {
149
159
  var clientX = mouseMoveEvent.clientX,
150
160
  clientY = mouseMoveEvent.clientY;
151
161
  var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
@@ -196,7 +206,8 @@ export function rowDrag(opt) {
196
206
  isFinished: true,
197
207
  dragPosition: dragPosition
198
208
  });
199
- handleDragEnd(dragEndEvent, isOutOfRange);
209
+ var isValid = isValidDrag && !isOutOfRange;
210
+ handleDragEnd(dragEndEvent, isValid);
200
211
  removeDragElement(dragElement);
201
212
  removeCurSorStyle();
202
213
  document.removeEventListener('scroll', scrollCallback, true);
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
4
+
3
5
  var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/map");
4
6
 
5
7
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
@@ -84,13 +86,13 @@ function rowDrag(opt) {
84
86
  pipeline.setStateAtKey(rowDragKey, event);
85
87
  };
86
88
 
87
- var handleDragEnd = function handleDragEnd(event, isOutOfRange) {
89
+ var handleDragEnd = function handleDragEnd(event, isValid) {
88
90
  var _a;
89
91
 
90
92
  artTable.classList.remove((0, _classnames.default)(_styles.Classes.rowDragging));
91
93
  pipeline.setStateAtKey(rowDragKey, event); // 超出拖拽范围不触发dragend事件
92
94
 
93
- if (!isOutOfRange) {
95
+ if (isValid) {
94
96
  (_a = opt === null || opt === void 0 ? void 0 : opt.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(opt, event);
95
97
  }
96
98
  };
@@ -135,6 +137,7 @@ function rowDrag(opt) {
135
137
 
136
138
  var dragPosition = 'bottom';
137
139
  var isOutOfRange = false;
140
+ var isValidDrag = false;
138
141
  var dragStartEvent = getDragEvent(startRowInfo, endRowInfo, {
139
142
  isFinished: false,
140
143
  dragPosition: 'bottom'
@@ -143,6 +146,7 @@ function rowDrag(opt) {
143
146
  var tableWidth = tableBody.clientWidth;
144
147
  var startRowRects = startRowInfo.cell.getBoundingClientRect(); // 光标位置距离初始拖拽行的偏移量
145
148
 
149
+ var mouseDownClientY = mouseDownEvent.clientY;
146
150
  var startOffset = mouseDownEvent.clientY - startRowRects.top;
147
151
  var dragElement = createDragElement(startRowRects, tableWidth, rowHeight); // 可拖拽的范围
148
152
 
@@ -169,7 +173,15 @@ function rowDrag(opt) {
169
173
  };
170
174
 
171
175
  document.addEventListener('scroll', scrollCallback, true);
172
- var rowDrag$ = mousemove$.pipe((0, _mapInstanceProperty(_operators))(function (mouseMoveEvent) {
176
+ var rowDrag$ = mousemove$.pipe((0, _filterInstanceProperty(_operators))(function (mouseMoveEvent) {
177
+ var mouseMoveClientY = mouseMoveEvent.clientY; // 上下移动偏移量大于5才是有效的拖拽
178
+
179
+ if (Math.abs(mouseMoveClientY - mouseDownClientY) > 5) {
180
+ isValidDrag = true;
181
+ }
182
+
183
+ return isValidDrag;
184
+ }), (0, _mapInstanceProperty(_operators))(function (mouseMoveEvent) {
173
185
  var clientX = mouseMoveEvent.clientX,
174
186
  clientY = mouseMoveEvent.clientY;
175
187
  var tagretRow = getTargetRowInfo(mouseMoveEvent.target, tableBody, dataSource);
@@ -220,7 +232,8 @@ function rowDrag(opt) {
220
232
  isFinished: true,
221
233
  dragPosition: dragPosition
222
234
  });
223
- handleDragEnd(dragEndEvent, isOutOfRange);
235
+ var isValid = isValidDrag && !isOutOfRange;
236
+ handleDragEnd(dragEndEvent, isValid);
224
237
  removeDragElement(dragElement);
225
238
  removeCurSorStyle();
226
239
  document.removeEventListener('scroll', scrollCallback, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/table",
3
- "version": "1.2.1-canary.4",
3
+ "version": "1.2.1-canary.5",
4
4
  "description": "金蝶 react table 组件",
5
5
  "title": "table",
6
6
  "keywords": [