@fonixtree/magic-design 1.0.206 → 1.0.207

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.
@@ -86,7 +86,8 @@ function (_super) {
86
86
  hoverState: false,
87
87
  isDragging: false,
88
88
  startX: 0,
89
- startY: 0
89
+ startY: 0,
90
+ hasDragged: false
90
91
  };
91
92
  _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
92
93
  _this.destroy = null;
@@ -160,7 +161,19 @@ function (_super) {
160
161
  _this.handleMouseMove = function (e) {
161
162
  if (!_this.state.isDragging) return; // 防止默认行为,避免选中文本
162
163
 
163
- e.preventDefault();
164
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
165
+
166
+ var _a = _this.state,
167
+ startX = _a.startX,
168
+ startY = _a.startY;
169
+ var deltaX = Math.abs(e.clientX - startX);
170
+ var deltaY = Math.abs(e.clientY - startY);
171
+
172
+ if (deltaX > 5 || deltaY > 5) {
173
+ _this.setState({
174
+ hasDragged: true
175
+ });
176
+ }
164
177
  };
165
178
 
166
179
  _this.handleMouseUp = function (e) {
@@ -170,7 +183,19 @@ function (_super) {
170
183
  _this.handleGlobalMouseMove = function (e) {
171
184
  if (!_this.state.isDragging) return; // 防止默认行为,避免选中文本
172
185
 
173
- e.preventDefault();
186
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
187
+
188
+ var _a = _this.state,
189
+ startX = _a.startX,
190
+ startY = _a.startY;
191
+ var deltaX = Math.abs(e.clientX - startX);
192
+ var deltaY = Math.abs(e.clientY - startY);
193
+
194
+ if (deltaX > 5 || deltaY > 5) {
195
+ _this.setState({
196
+ hasDragged: true
197
+ });
198
+ }
174
199
  };
175
200
 
176
201
  _this.handleGlobalMouseUp = function (e) {
@@ -185,16 +210,10 @@ function (_super) {
185
210
  if (!_this.state.isDragging) return;
186
211
  var _c = _this.state,
187
212
  startX = _c.startX,
188
- startY = _c.startY;
213
+ startY = _c.startY,
214
+ hasDragged = _c.hasDragged;
189
215
  var deltaX = startX - endX;
190
- var deltaY = startY - endY; // 重置拖拽状态
191
-
192
- _this.setState({
193
- isDragging: false,
194
- startX: 0,
195
- startY: 0
196
- }); // 判断是否为水平滑动(水平距离大于垂直距离,且水平距离超过阈值)
197
-
216
+ var deltaY = startY - endY; // 判断是否为水平滑动(水平距离大于垂直距离,且水平距离超过阈值)
198
217
 
199
218
  var minSwipeDistance = 50; // 最小滑动距离阈值
200
219
 
@@ -206,17 +225,75 @@ function (_super) {
206
225
  // 向右滑动,切换到上一页
207
226
  (_b = _this.carouselRef.current) === null || _b === void 0 ? void 0 : _b.prev();
208
227
  }
228
+ } // 如果发生了拖拽,延迟重置以便阻止点击事件
229
+ // 如果没有拖拽,立即重置,允许点击事件正常触发
230
+
231
+
232
+ if (hasDragged) {
233
+ setTimeout(function () {
234
+ _this.setState({
235
+ isDragging: false,
236
+ startX: 0,
237
+ startY: 0,
238
+ hasDragged: false
239
+ });
240
+ }, 100);
241
+ } else {
242
+ // 没有拖拽,立即重置,允许点击
243
+ _this.setState({
244
+ isDragging: false,
245
+ startX: 0,
246
+ startY: 0,
247
+ hasDragged: false
248
+ });
209
249
  }
210
250
  };
211
251
 
212
252
  _this.handleMouseLeave = function () {
213
253
  // 鼠标离开时重置拖拽状态
214
254
  if (_this.state.isDragging) {
215
- _this.setState({
216
- isDragging: false,
217
- startX: 0,
218
- startY: 0
219
- });
255
+ var hasDragged = _this.state.hasDragged;
256
+
257
+ if (hasDragged) {
258
+ setTimeout(function () {
259
+ _this.setState({
260
+ isDragging: false,
261
+ startX: 0,
262
+ startY: 0,
263
+ hasDragged: false
264
+ });
265
+ }, 100);
266
+ } else {
267
+ // 没有拖拽,立即重置
268
+ _this.setState({
269
+ isDragging: false,
270
+ startX: 0,
271
+ startY: 0,
272
+ hasDragged: false
273
+ });
274
+ }
275
+ }
276
+ }; // 阻止拖拽后的点击事件 - 使用捕获阶段
277
+
278
+
279
+ _this.handleClickCapture = function (e) {
280
+ // 只有在真正发生拖拽时才阻止点击
281
+ if (_this.state.hasDragged) {
282
+ e.preventDefault();
283
+ e.stopPropagation(); // 阻止所有子元素的点击事件
284
+
285
+ e.nativeEvent.stopImmediatePropagation();
286
+ }
287
+ }; // 阻止拖拽后的点击事件
288
+
289
+
290
+ _this.handleClick = function (e) {
291
+ // 只有在真正发生拖拽时才阻止点击
292
+ if (_this.state.hasDragged) {
293
+ e.preventDefault();
294
+ e.stopPropagation(); // 阻止所有子元素的点击事件
295
+
296
+ e.nativeEvent.stopImmediatePropagation();
220
297
  }
221
298
  }; // padding用统一设置
222
299
 
@@ -350,7 +427,8 @@ function (_super) {
350
427
  style: _this.getBackgroundStyle(item)
351
428
  }, /*#__PURE__*/_react["default"].createElement("div", {
352
429
  className: (0, _classnames["default"])('carouselItem', {
353
- dragging: _this.state.isDragging
430
+ dragging: _this.state.isDragging,
431
+ 'no-click': _this.state.hasDragged
354
432
  }),
355
433
  onMouseEnter: _this.mouseEnterWrap,
356
434
  onMouseLeave: function onMouseLeave(e) {
@@ -361,6 +439,8 @@ function (_super) {
361
439
  onMouseDown: _this.handleMouseDown,
362
440
  onMouseMove: _this.handleMouseMove,
363
441
  onMouseUp: _this.handleMouseUp,
442
+ onClick: _this.handleClick,
443
+ onClickCapture: _this.handleClickCapture,
364
444
  style: __assign(__assign({}, _this.getItemStyle(item)), {
365
445
  cursor: _this.state.isDragging ? 'grabbing' : !(0, _coreUtil.isDesignMode)() || ((_a = window.magicDesign) === null || _a === void 0 ? void 0 : _a.mode) === 'renderer' ? 'grab' : 'default'
366
446
  })
@@ -63,6 +63,13 @@
63
63
  cursor: grabbing !important;
64
64
  }
65
65
 
66
+ // 拖拽时禁用子元素的点击事件
67
+ &.no-click {
68
+ * {
69
+ pointer-events: none !important;
70
+ }
71
+ }
72
+
66
73
  .carouseContent {
67
74
  padding: 0 80px;
68
75
  position: absolute;
@@ -7,6 +7,8 @@ exports["default"] = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+
10
12
  require("./index.less");
11
13
 
12
14
  var _lodash = _interopRequireDefault(require("lodash.throttle"));
@@ -310,7 +312,8 @@ function (_super) {
310
312
  scrollToRightDisabled: true,
311
313
  isDragging: false,
312
314
  startX: 0,
313
- startScrollLeft: 0
315
+ startScrollLeft: 0,
316
+ hasDragged: false
314
317
  };
315
318
 
316
319
  _this.getFlashData = function (pageSize, campaign) {
@@ -450,46 +453,131 @@ function (_super) {
450
453
 
451
454
  _this.handleMouseMove = function (e) {
452
455
  if (!_this.state.isDragging) return;
453
- e.preventDefault();
456
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
457
+
458
+ var startX = _this.state.startX;
459
+ var deltaX = Math.abs(e.clientX - startX);
460
+
461
+ if (deltaX > 5) {
462
+ _this.setState({
463
+ hasDragged: true
464
+ });
465
+ }
454
466
 
455
467
  _this.updateScrollPosition(e.clientX);
456
468
  };
457
469
 
458
470
  _this.handleGlobalMouseMove = function (e) {
459
471
  if (!_this.state.isDragging) return;
460
- e.preventDefault();
472
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
473
+
474
+ var startX = _this.state.startX;
475
+ var deltaX = Math.abs(e.clientX - startX);
476
+
477
+ if (deltaX > 5) {
478
+ _this.setState({
479
+ hasDragged: true
480
+ });
481
+ }
461
482
 
462
483
  _this.updateScrollPosition(e.clientX);
463
484
  };
464
485
 
465
486
  _this.handleGlobalMouseUp = function (e) {
466
487
  if (!_this.state.isDragging) return;
467
-
468
- _this.setState({
469
- isDragging: false,
470
- startX: 0,
471
- startScrollLeft: 0
472
- });
488
+ var hasDragged = _this.state.hasDragged; // 如果发生了拖拽,延迟重置以便阻止点击事件
489
+ // 如果没有拖拽,立即重置,允许点击事件正常触发
490
+
491
+ if (hasDragged) {
492
+ setTimeout(function () {
493
+ _this.setState({
494
+ isDragging: false,
495
+ startX: 0,
496
+ startScrollLeft: 0,
497
+ hasDragged: false
498
+ });
499
+ }, 100);
500
+ } else {
501
+ // 没有拖拽,立即重置,允许点击
502
+ _this.setState({
503
+ isDragging: false,
504
+ startX: 0,
505
+ startScrollLeft: 0,
506
+ hasDragged: false
507
+ });
508
+ }
473
509
  };
474
510
 
475
511
  _this.handleMouseUp = function (e) {
476
512
  if (!_this.state.isDragging) return;
477
-
478
- _this.setState({
479
- isDragging: false,
480
- startX: 0,
481
- startScrollLeft: 0
482
- });
513
+ var hasDragged = _this.state.hasDragged; // 如果发生了拖拽,延迟重置以便阻止点击事件
514
+ // 如果没有拖拽,立即重置,允许点击事件正常触发
515
+
516
+ if (hasDragged) {
517
+ setTimeout(function () {
518
+ _this.setState({
519
+ isDragging: false,
520
+ startX: 0,
521
+ startScrollLeft: 0,
522
+ hasDragged: false
523
+ });
524
+ }, 100);
525
+ } else {
526
+ // 没有拖拽,立即重置,允许点击
527
+ _this.setState({
528
+ isDragging: false,
529
+ startX: 0,
530
+ startScrollLeft: 0,
531
+ hasDragged: false
532
+ });
533
+ }
483
534
  };
484
535
 
485
536
  _this.handleMouseLeave = function () {
486
537
  // 鼠标离开时重置拖拽状态
487
538
  if (_this.state.isDragging) {
488
- _this.setState({
489
- isDragging: false,
490
- startX: 0,
491
- startScrollLeft: 0
492
- });
539
+ var hasDragged = _this.state.hasDragged;
540
+
541
+ if (hasDragged) {
542
+ setTimeout(function () {
543
+ _this.setState({
544
+ isDragging: false,
545
+ startX: 0,
546
+ startScrollLeft: 0,
547
+ hasDragged: false
548
+ });
549
+ }, 100);
550
+ } else {
551
+ // 没有拖拽,立即重置
552
+ _this.setState({
553
+ isDragging: false,
554
+ startX: 0,
555
+ startScrollLeft: 0,
556
+ hasDragged: false
557
+ });
558
+ }
559
+ }
560
+ }; // 阻止拖拽后的点击事件 - 使用捕获阶段
561
+
562
+
563
+ _this.handleClickCapture = function (e) {
564
+ // 只有在真正发生拖拽时才阻止点击
565
+ if (_this.state.hasDragged) {
566
+ e.preventDefault();
567
+ e.stopPropagation(); // 阻止所有子元素的点击事件
568
+
569
+ e.nativeEvent.stopImmediatePropagation();
570
+ }
571
+ }; // 阻止拖拽后的点击事件
572
+
573
+
574
+ _this.handleClick = function (e) {
575
+ // 只有在真正发生拖拽时才阻止点击
576
+ if (_this.state.hasDragged) {
577
+ e.preventDefault();
578
+ e.stopPropagation(); // 阻止所有子元素的点击事件
579
+
580
+ e.nativeEvent.stopImmediatePropagation();
493
581
  }
494
582
  };
495
583
 
@@ -622,11 +710,15 @@ function (_super) {
622
710
  type: "icon-outlined-left"
623
711
  })), /*#__PURE__*/_react["default"].createElement("div", {
624
712
  ref: this.scrollRef,
625
- className: "flash-deal-list",
713
+ className: (0, _classnames["default"])('flash-deal-list', {
714
+ 'no-click': this.state.hasDragged
715
+ }),
626
716
  onMouseDown: this.handleMouseDown,
627
717
  onMouseMove: this.handleMouseMove,
628
718
  onMouseUp: this.handleMouseUp,
629
719
  onMouseLeave: this.handleMouseLeave,
720
+ onClick: this.handleClick,
721
+ onClickCapture: this.handleClickCapture,
630
722
  style: {
631
723
  cursor: this.state.isDragging ? 'grabbing' : !(0, _coreUtil.isDesignMode)() || ((_c = window.magicDesign) === null || _c === void 0 ? void 0 : _c.mode) === 'renderer' ? 'grab' : 'default'
632
724
  }
@@ -110,6 +110,13 @@
110
110
  &.dragging {
111
111
  cursor: grabbing !important;
112
112
  }
113
+
114
+ // 拖拽时禁用子元素的点击事件
115
+ &.no-click {
116
+ * {
117
+ pointer-events: none !important;
118
+ }
119
+ }
113
120
  }
114
121
  }
115
122
 
@@ -86,7 +86,8 @@ function (_super) {
86
86
  hoverState: false,
87
87
  isDragging: false,
88
88
  startX: 0,
89
- startY: 0
89
+ startY: 0,
90
+ hasDragged: false
90
91
  };
91
92
  _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
92
93
  _this.destroy = null;
@@ -160,7 +161,19 @@ function (_super) {
160
161
  _this.handleMouseMove = function (e) {
161
162
  if (!_this.state.isDragging) return; // 防止默认行为,避免选中文本
162
163
 
163
- e.preventDefault();
164
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
165
+
166
+ var _a = _this.state,
167
+ startX = _a.startX,
168
+ startY = _a.startY;
169
+ var deltaX = Math.abs(e.clientX - startX);
170
+ var deltaY = Math.abs(e.clientY - startY);
171
+
172
+ if (deltaX > 5 || deltaY > 5) {
173
+ _this.setState({
174
+ hasDragged: true
175
+ });
176
+ }
164
177
  };
165
178
 
166
179
  _this.handleMouseUp = function (e) {
@@ -170,7 +183,19 @@ function (_super) {
170
183
  _this.handleGlobalMouseMove = function (e) {
171
184
  if (!_this.state.isDragging) return; // 防止默认行为,避免选中文本
172
185
 
173
- e.preventDefault();
186
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
187
+
188
+ var _a = _this.state,
189
+ startX = _a.startX,
190
+ startY = _a.startY;
191
+ var deltaX = Math.abs(e.clientX - startX);
192
+ var deltaY = Math.abs(e.clientY - startY);
193
+
194
+ if (deltaX > 5 || deltaY > 5) {
195
+ _this.setState({
196
+ hasDragged: true
197
+ });
198
+ }
174
199
  };
175
200
 
176
201
  _this.handleGlobalMouseUp = function (e) {
@@ -185,16 +210,10 @@ function (_super) {
185
210
  if (!_this.state.isDragging) return;
186
211
  var _c = _this.state,
187
212
  startX = _c.startX,
188
- startY = _c.startY;
213
+ startY = _c.startY,
214
+ hasDragged = _c.hasDragged;
189
215
  var deltaX = startX - endX;
190
- var deltaY = startY - endY; // 重置拖拽状态
191
-
192
- _this.setState({
193
- isDragging: false,
194
- startX: 0,
195
- startY: 0
196
- }); // 判断是否为水平滑动(水平距离大于垂直距离,且水平距离超过阈值)
197
-
216
+ var deltaY = startY - endY; // 判断是否为水平滑动(水平距离大于垂直距离,且水平距离超过阈值)
198
217
 
199
218
  var minSwipeDistance = 50; // 最小滑动距离阈值
200
219
 
@@ -206,17 +225,75 @@ function (_super) {
206
225
  // 向右滑动,切换到上一页
207
226
  (_b = _this.carouselRef.current) === null || _b === void 0 ? void 0 : _b.prev();
208
227
  }
228
+ } // 如果发生了拖拽,延迟重置以便阻止点击事件
229
+ // 如果没有拖拽,立即重置,允许点击事件正常触发
230
+
231
+
232
+ if (hasDragged) {
233
+ setTimeout(function () {
234
+ _this.setState({
235
+ isDragging: false,
236
+ startX: 0,
237
+ startY: 0,
238
+ hasDragged: false
239
+ });
240
+ }, 100);
241
+ } else {
242
+ // 没有拖拽,立即重置,允许点击
243
+ _this.setState({
244
+ isDragging: false,
245
+ startX: 0,
246
+ startY: 0,
247
+ hasDragged: false
248
+ });
209
249
  }
210
250
  };
211
251
 
212
252
  _this.handleMouseLeave = function () {
213
253
  // 鼠标离开时重置拖拽状态
214
254
  if (_this.state.isDragging) {
215
- _this.setState({
216
- isDragging: false,
217
- startX: 0,
218
- startY: 0
219
- });
255
+ var hasDragged = _this.state.hasDragged;
256
+
257
+ if (hasDragged) {
258
+ setTimeout(function () {
259
+ _this.setState({
260
+ isDragging: false,
261
+ startX: 0,
262
+ startY: 0,
263
+ hasDragged: false
264
+ });
265
+ }, 100);
266
+ } else {
267
+ // 没有拖拽,立即重置
268
+ _this.setState({
269
+ isDragging: false,
270
+ startX: 0,
271
+ startY: 0,
272
+ hasDragged: false
273
+ });
274
+ }
275
+ }
276
+ }; // 阻止拖拽后的点击事件 - 使用捕获阶段
277
+
278
+
279
+ _this.handleClickCapture = function (e) {
280
+ // 只有在真正发生拖拽时才阻止点击
281
+ if (_this.state.hasDragged) {
282
+ e.preventDefault();
283
+ e.stopPropagation(); // 阻止所有子元素的点击事件
284
+
285
+ e.nativeEvent.stopImmediatePropagation();
286
+ }
287
+ }; // 阻止拖拽后的点击事件
288
+
289
+
290
+ _this.handleClick = function (e) {
291
+ // 只有在真正发生拖拽时才阻止点击
292
+ if (_this.state.hasDragged) {
293
+ e.preventDefault();
294
+ e.stopPropagation(); // 阻止所有子元素的点击事件
295
+
296
+ e.nativeEvent.stopImmediatePropagation();
220
297
  }
221
298
  }; // padding用统一设置
222
299
 
@@ -350,7 +427,8 @@ function (_super) {
350
427
  style: _this.getBackgroundStyle(item)
351
428
  }, /*#__PURE__*/_react["default"].createElement("div", {
352
429
  className: (0, _classnames["default"])('carouselItem', {
353
- dragging: _this.state.isDragging
430
+ dragging: _this.state.isDragging,
431
+ 'no-click': _this.state.hasDragged
354
432
  }),
355
433
  onMouseEnter: _this.mouseEnterWrap,
356
434
  onMouseLeave: function onMouseLeave(e) {
@@ -361,6 +439,8 @@ function (_super) {
361
439
  onMouseDown: _this.handleMouseDown,
362
440
  onMouseMove: _this.handleMouseMove,
363
441
  onMouseUp: _this.handleMouseUp,
442
+ onClick: _this.handleClick,
443
+ onClickCapture: _this.handleClickCapture,
364
444
  style: __assign(__assign({}, _this.getItemStyle(item)), {
365
445
  cursor: _this.state.isDragging ? 'grabbing' : !(0, _coreUtil.isDesignMode)() || ((_a = window.magicDesign) === null || _a === void 0 ? void 0 : _a.mode) === 'renderer' ? 'grab' : 'default'
366
446
  })
@@ -63,6 +63,13 @@
63
63
  cursor: grabbing !important;
64
64
  }
65
65
 
66
+ // 拖拽时禁用子元素的点击事件
67
+ &.no-click {
68
+ * {
69
+ pointer-events: none !important;
70
+ }
71
+ }
72
+
66
73
  .carouseContent {
67
74
  padding: 0 80px;
68
75
  position: absolute;
@@ -7,6 +7,8 @@ exports["default"] = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+
10
12
  require("./index.less");
11
13
 
12
14
  var _lodash = _interopRequireDefault(require("lodash.throttle"));
@@ -310,7 +312,8 @@ function (_super) {
310
312
  scrollToRightDisabled: true,
311
313
  isDragging: false,
312
314
  startX: 0,
313
- startScrollLeft: 0
315
+ startScrollLeft: 0,
316
+ hasDragged: false
314
317
  };
315
318
 
316
319
  _this.getFlashData = function (pageSize, campaign) {
@@ -450,46 +453,131 @@ function (_super) {
450
453
 
451
454
  _this.handleMouseMove = function (e) {
452
455
  if (!_this.state.isDragging) return;
453
- e.preventDefault();
456
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
457
+
458
+ var startX = _this.state.startX;
459
+ var deltaX = Math.abs(e.clientX - startX);
460
+
461
+ if (deltaX > 5) {
462
+ _this.setState({
463
+ hasDragged: true
464
+ });
465
+ }
454
466
 
455
467
  _this.updateScrollPosition(e.clientX);
456
468
  };
457
469
 
458
470
  _this.handleGlobalMouseMove = function (e) {
459
471
  if (!_this.state.isDragging) return;
460
- e.preventDefault();
472
+ e.preventDefault(); // 如果移动距离超过阈值,标记为已拖拽
473
+
474
+ var startX = _this.state.startX;
475
+ var deltaX = Math.abs(e.clientX - startX);
476
+
477
+ if (deltaX > 5) {
478
+ _this.setState({
479
+ hasDragged: true
480
+ });
481
+ }
461
482
 
462
483
  _this.updateScrollPosition(e.clientX);
463
484
  };
464
485
 
465
486
  _this.handleGlobalMouseUp = function (e) {
466
487
  if (!_this.state.isDragging) return;
467
-
468
- _this.setState({
469
- isDragging: false,
470
- startX: 0,
471
- startScrollLeft: 0
472
- });
488
+ var hasDragged = _this.state.hasDragged; // 如果发生了拖拽,延迟重置以便阻止点击事件
489
+ // 如果没有拖拽,立即重置,允许点击事件正常触发
490
+
491
+ if (hasDragged) {
492
+ setTimeout(function () {
493
+ _this.setState({
494
+ isDragging: false,
495
+ startX: 0,
496
+ startScrollLeft: 0,
497
+ hasDragged: false
498
+ });
499
+ }, 100);
500
+ } else {
501
+ // 没有拖拽,立即重置,允许点击
502
+ _this.setState({
503
+ isDragging: false,
504
+ startX: 0,
505
+ startScrollLeft: 0,
506
+ hasDragged: false
507
+ });
508
+ }
473
509
  };
474
510
 
475
511
  _this.handleMouseUp = function (e) {
476
512
  if (!_this.state.isDragging) return;
477
-
478
- _this.setState({
479
- isDragging: false,
480
- startX: 0,
481
- startScrollLeft: 0
482
- });
513
+ var hasDragged = _this.state.hasDragged; // 如果发生了拖拽,延迟重置以便阻止点击事件
514
+ // 如果没有拖拽,立即重置,允许点击事件正常触发
515
+
516
+ if (hasDragged) {
517
+ setTimeout(function () {
518
+ _this.setState({
519
+ isDragging: false,
520
+ startX: 0,
521
+ startScrollLeft: 0,
522
+ hasDragged: false
523
+ });
524
+ }, 100);
525
+ } else {
526
+ // 没有拖拽,立即重置,允许点击
527
+ _this.setState({
528
+ isDragging: false,
529
+ startX: 0,
530
+ startScrollLeft: 0,
531
+ hasDragged: false
532
+ });
533
+ }
483
534
  };
484
535
 
485
536
  _this.handleMouseLeave = function () {
486
537
  // 鼠标离开时重置拖拽状态
487
538
  if (_this.state.isDragging) {
488
- _this.setState({
489
- isDragging: false,
490
- startX: 0,
491
- startScrollLeft: 0
492
- });
539
+ var hasDragged = _this.state.hasDragged;
540
+
541
+ if (hasDragged) {
542
+ setTimeout(function () {
543
+ _this.setState({
544
+ isDragging: false,
545
+ startX: 0,
546
+ startScrollLeft: 0,
547
+ hasDragged: false
548
+ });
549
+ }, 100);
550
+ } else {
551
+ // 没有拖拽,立即重置
552
+ _this.setState({
553
+ isDragging: false,
554
+ startX: 0,
555
+ startScrollLeft: 0,
556
+ hasDragged: false
557
+ });
558
+ }
559
+ }
560
+ }; // 阻止拖拽后的点击事件 - 使用捕获阶段
561
+
562
+
563
+ _this.handleClickCapture = function (e) {
564
+ // 只有在真正发生拖拽时才阻止点击
565
+ if (_this.state.hasDragged) {
566
+ e.preventDefault();
567
+ e.stopPropagation(); // 阻止所有子元素的点击事件
568
+
569
+ e.nativeEvent.stopImmediatePropagation();
570
+ }
571
+ }; // 阻止拖拽后的点击事件
572
+
573
+
574
+ _this.handleClick = function (e) {
575
+ // 只有在真正发生拖拽时才阻止点击
576
+ if (_this.state.hasDragged) {
577
+ e.preventDefault();
578
+ e.stopPropagation(); // 阻止所有子元素的点击事件
579
+
580
+ e.nativeEvent.stopImmediatePropagation();
493
581
  }
494
582
  };
495
583
 
@@ -622,11 +710,15 @@ function (_super) {
622
710
  type: "icon-outlined-left"
623
711
  })), /*#__PURE__*/_react["default"].createElement("div", {
624
712
  ref: this.scrollRef,
625
- className: "flash-deal-list",
713
+ className: (0, _classnames["default"])('flash-deal-list', {
714
+ 'no-click': this.state.hasDragged
715
+ }),
626
716
  onMouseDown: this.handleMouseDown,
627
717
  onMouseMove: this.handleMouseMove,
628
718
  onMouseUp: this.handleMouseUp,
629
719
  onMouseLeave: this.handleMouseLeave,
720
+ onClick: this.handleClick,
721
+ onClickCapture: this.handleClickCapture,
630
722
  style: {
631
723
  cursor: this.state.isDragging ? 'grabbing' : !(0, _coreUtil.isDesignMode)() || ((_c = window.magicDesign) === null || _c === void 0 ? void 0 : _c.mode) === 'renderer' ? 'grab' : 'default'
632
724
  }
@@ -110,6 +110,13 @@
110
110
  &.dragging {
111
111
  cursor: grabbing !important;
112
112
  }
113
+
114
+ // 拖拽时禁用子元素的点击事件
115
+ &.no-click {
116
+ * {
117
+ pointer-events: none !important;
118
+ }
119
+ }
113
120
  }
114
121
  }
115
122
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "1.0.206",
4
+ "version": "1.0.207",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",