@douyinfe/semi-foundation 2.23.0-beta.0 → 2.23.0

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.
Files changed (180) hide show
  1. package/anchor/animation.scss +2 -2
  2. package/autoComplete/animation.scss +2 -2
  3. package/breadcrumb/animation.scss +2 -2
  4. package/button/animation.scss +26 -26
  5. package/carousel/animation.scss +2 -2
  6. package/cascader/animation.scss +2 -2
  7. package/cascader/cascader.scss +15 -0
  8. package/cascader/variables.scss +1 -0
  9. package/checkbox/animation.scss +4 -4
  10. package/checkbox/variables.scss +1 -1
  11. package/collapsible/animation.scss +2 -2
  12. package/datePicker/animation.scss +2 -2
  13. package/dropdown/animation.scss +1 -1
  14. package/dropdown/foundation.ts +16 -9
  15. package/dropdown/menuFoundation.ts +1 -12
  16. package/form/form.scss +3 -4
  17. package/form/rtl.scss +0 -1
  18. package/form/variables.scss +38 -35
  19. package/input/animation.scss +6 -6
  20. package/inputNumber/animation.scss +4 -4
  21. package/lib/cjs/anchor/anchor.css +1 -1
  22. package/lib/cjs/anchor/animation.scss +2 -2
  23. package/lib/cjs/autoComplete/animation.scss +2 -2
  24. package/lib/cjs/autoComplete/autoComplete.css +1 -1
  25. package/lib/cjs/breadcrumb/animation.scss +2 -2
  26. package/lib/cjs/breadcrumb/breadcrumb.css +1 -1
  27. package/lib/cjs/button/animation.scss +26 -26
  28. package/lib/cjs/button/button.css +7 -7
  29. package/lib/cjs/carousel/animation.scss +2 -2
  30. package/lib/cjs/carousel/carousel.css +6 -6
  31. package/lib/cjs/cascader/animation.scss +2 -2
  32. package/lib/cjs/cascader/cascader.css +13 -1
  33. package/lib/cjs/cascader/cascader.scss +15 -0
  34. package/lib/cjs/cascader/variables.scss +1 -0
  35. package/lib/cjs/checkbox/animation.scss +4 -4
  36. package/lib/cjs/checkbox/checkbox.css +2 -2
  37. package/lib/cjs/checkbox/variables.scss +1 -1
  38. package/lib/cjs/collapsible/animation.scss +2 -2
  39. package/lib/cjs/collapsible/collapsible.css +1 -1
  40. package/lib/cjs/datePicker/animation.scss +2 -2
  41. package/lib/cjs/dropdown/animation.scss +1 -1
  42. package/lib/cjs/dropdown/dropdown.css +1 -1
  43. package/lib/cjs/dropdown/foundation.d.ts +4 -3
  44. package/lib/cjs/dropdown/foundation.js +21 -8
  45. package/lib/cjs/dropdown/menuFoundation.d.ts +0 -1
  46. package/lib/cjs/dropdown/menuFoundation.js +0 -11
  47. package/lib/cjs/form/form.css +0 -2
  48. package/lib/cjs/form/form.scss +3 -4
  49. package/lib/cjs/form/rtl.scss +0 -1
  50. package/lib/cjs/form/variables.scss +38 -35
  51. package/lib/cjs/input/animation.scss +6 -6
  52. package/lib/cjs/input/input.css +2 -2
  53. package/lib/cjs/input/textarea.css +1 -1
  54. package/lib/cjs/inputNumber/animation.scss +4 -4
  55. package/lib/cjs/inputNumber/inputNumber.css +1 -1
  56. package/lib/cjs/navigation/animation.scss +2 -2
  57. package/lib/cjs/navigation/navigation.css +1 -1
  58. package/lib/cjs/pagination/animation.scss +4 -4
  59. package/lib/cjs/pagination/pagination.css +1 -1
  60. package/lib/cjs/radio/animation.scss +4 -4
  61. package/lib/cjs/radio/radio.css +4 -4
  62. package/lib/cjs/rating/animation.scss +2 -2
  63. package/lib/cjs/rating/rating.css +1 -1
  64. package/lib/cjs/scrollList/animation.scss +1 -1
  65. package/lib/cjs/scrollList/scrollList.css +1 -1
  66. package/lib/cjs/select/animation.scss +6 -6
  67. package/lib/cjs/select/select.css +2 -2
  68. package/lib/cjs/slider/animation.scss +2 -2
  69. package/lib/cjs/slider/slider.css +1 -1
  70. package/lib/cjs/steps/animation.scss +6 -6
  71. package/lib/cjs/steps/steps.css +7 -7
  72. package/lib/cjs/switch/animation.scss +1 -1
  73. package/lib/cjs/switch/switch.css +1 -1
  74. package/lib/cjs/table/animation.scss +1 -1
  75. package/lib/cjs/table/table.css +2 -2
  76. package/lib/cjs/tabs/animation.scss +8 -8
  77. package/lib/cjs/tabs/tabs.css +46 -6
  78. package/lib/cjs/tabs/tabs.scss +43 -2
  79. package/lib/cjs/tabs/variables.scss +20 -0
  80. package/lib/cjs/tagInput/animation.scss +4 -4
  81. package/lib/cjs/tagInput/tagInput.css +1 -1
  82. package/lib/cjs/timePicker/utils/animation.scss +4 -4
  83. package/lib/cjs/tooltip/constants.d.ts +1 -0
  84. package/lib/cjs/tooltip/constants.js +2 -2
  85. package/lib/cjs/tooltip/foundation.d.ts +21 -2
  86. package/lib/cjs/tooltip/foundation.js +360 -77
  87. package/lib/cjs/transfer/animation.scss +2 -2
  88. package/lib/cjs/transfer/transfer.css +1 -1
  89. package/lib/cjs/tree/animation.scss +2 -2
  90. package/lib/cjs/tree/tree.css +1 -1
  91. package/lib/es/anchor/anchor.css +1 -1
  92. package/lib/es/anchor/animation.scss +2 -2
  93. package/lib/es/autoComplete/animation.scss +2 -2
  94. package/lib/es/autoComplete/autoComplete.css +1 -1
  95. package/lib/es/breadcrumb/animation.scss +2 -2
  96. package/lib/es/breadcrumb/breadcrumb.css +1 -1
  97. package/lib/es/button/animation.scss +26 -26
  98. package/lib/es/button/button.css +7 -7
  99. package/lib/es/carousel/animation.scss +2 -2
  100. package/lib/es/carousel/carousel.css +6 -6
  101. package/lib/es/cascader/animation.scss +2 -2
  102. package/lib/es/cascader/cascader.css +13 -1
  103. package/lib/es/cascader/cascader.scss +15 -0
  104. package/lib/es/cascader/variables.scss +1 -0
  105. package/lib/es/checkbox/animation.scss +4 -4
  106. package/lib/es/checkbox/checkbox.css +2 -2
  107. package/lib/es/checkbox/variables.scss +1 -1
  108. package/lib/es/collapsible/animation.scss +2 -2
  109. package/lib/es/collapsible/collapsible.css +1 -1
  110. package/lib/es/datePicker/animation.scss +2 -2
  111. package/lib/es/dropdown/animation.scss +1 -1
  112. package/lib/es/dropdown/dropdown.css +1 -1
  113. package/lib/es/dropdown/foundation.d.ts +4 -3
  114. package/lib/es/dropdown/foundation.js +21 -8
  115. package/lib/es/dropdown/menuFoundation.d.ts +0 -1
  116. package/lib/es/dropdown/menuFoundation.js +1 -12
  117. package/lib/es/form/form.css +0 -2
  118. package/lib/es/form/form.scss +3 -4
  119. package/lib/es/form/rtl.scss +0 -1
  120. package/lib/es/form/variables.scss +38 -35
  121. package/lib/es/input/animation.scss +6 -6
  122. package/lib/es/input/input.css +2 -2
  123. package/lib/es/input/textarea.css +1 -1
  124. package/lib/es/inputNumber/animation.scss +4 -4
  125. package/lib/es/inputNumber/inputNumber.css +1 -1
  126. package/lib/es/navigation/animation.scss +2 -2
  127. package/lib/es/navigation/navigation.css +1 -1
  128. package/lib/es/pagination/animation.scss +4 -4
  129. package/lib/es/pagination/pagination.css +1 -1
  130. package/lib/es/radio/animation.scss +4 -4
  131. package/lib/es/radio/radio.css +4 -4
  132. package/lib/es/rating/animation.scss +2 -2
  133. package/lib/es/rating/rating.css +1 -1
  134. package/lib/es/scrollList/animation.scss +1 -1
  135. package/lib/es/scrollList/scrollList.css +1 -1
  136. package/lib/es/select/animation.scss +6 -6
  137. package/lib/es/select/select.css +2 -2
  138. package/lib/es/slider/animation.scss +2 -2
  139. package/lib/es/slider/slider.css +1 -1
  140. package/lib/es/steps/animation.scss +6 -6
  141. package/lib/es/steps/steps.css +7 -7
  142. package/lib/es/switch/animation.scss +1 -1
  143. package/lib/es/switch/switch.css +1 -1
  144. package/lib/es/table/animation.scss +1 -1
  145. package/lib/es/table/table.css +2 -2
  146. package/lib/es/tabs/animation.scss +8 -8
  147. package/lib/es/tabs/tabs.css +46 -6
  148. package/lib/es/tabs/tabs.scss +43 -2
  149. package/lib/es/tabs/variables.scss +20 -0
  150. package/lib/es/tagInput/animation.scss +4 -4
  151. package/lib/es/tagInput/tagInput.css +1 -1
  152. package/lib/es/timePicker/utils/animation.scss +4 -4
  153. package/lib/es/tooltip/constants.d.ts +1 -0
  154. package/lib/es/tooltip/constants.js +2 -2
  155. package/lib/es/tooltip/foundation.d.ts +21 -2
  156. package/lib/es/tooltip/foundation.js +360 -77
  157. package/lib/es/transfer/animation.scss +2 -2
  158. package/lib/es/transfer/transfer.css +1 -1
  159. package/lib/es/tree/animation.scss +2 -2
  160. package/lib/es/tree/tree.css +1 -1
  161. package/navigation/animation.scss +2 -2
  162. package/package.json +2 -2
  163. package/pagination/animation.scss +4 -4
  164. package/radio/animation.scss +4 -4
  165. package/rating/animation.scss +2 -2
  166. package/scrollList/animation.scss +1 -1
  167. package/select/animation.scss +6 -6
  168. package/slider/animation.scss +2 -2
  169. package/steps/animation.scss +6 -6
  170. package/switch/animation.scss +1 -1
  171. package/table/animation.scss +1 -1
  172. package/tabs/animation.scss +8 -8
  173. package/tabs/tabs.scss +43 -2
  174. package/tabs/variables.scss +20 -0
  175. package/tagInput/animation.scss +4 -4
  176. package/timePicker/utils/animation.scss +4 -4
  177. package/tooltip/constants.ts +1 -0
  178. package/tooltip/foundation.ts +322 -78
  179. package/transfer/animation.scss +2 -2
  180. package/tree/animation.scss +2 -2
@@ -65,6 +65,14 @@ class Tooltip extends _foundation.default {
65
65
  const content = this.getProp('content');
66
66
  const trigger = this.getProp('trigger');
67
67
  const clickTriggerToHide = this.getProp('clickTriggerToHide');
68
+ const {
69
+ visible
70
+ } = this.getStates();
71
+
72
+ if (visible) {
73
+ return;
74
+ }
75
+
68
76
  this.clearDelayTimer();
69
77
  /**
70
78
  * If you emit an event in setState callback, you need to place the event listener function before setState to execute.
@@ -80,9 +88,11 @@ class Tooltip extends _foundation.default {
80
88
  this._togglePortalVisible(true);
81
89
  });
82
90
 
83
- const position = this.calcPosition(null, null, null, false);
91
+ this._adapter.insertPortal(content, {
92
+ left: -9999,
93
+ top: -9999
94
+ }); // offscreen rendering
84
95
 
85
- this._adapter.insertPortal(content, position);
86
96
 
87
97
  if (trigger === 'custom') {
88
98
  // eslint-disable-next-line
@@ -128,17 +138,32 @@ class Tooltip extends _foundation.default {
128
138
  containerRect = ((0, _isEmpty2.default)(containerRect) ? _this._adapter.getPopupContainerRect() : containerRect) || Object.assign({}, defaultRect);
129
139
  wrapperRect = ((0, _isEmpty2.default)(wrapperRect) ? _this._adapter.getWrapperBounding() : wrapperRect) || Object.assign({}, defaultRect); // console.log('containerRect: ', containerRect, 'triggerRect: ', triggerRect, 'wrapperRect: ', wrapperRect);
130
140
 
131
- let style = _this.calcPosStyle(triggerRect, wrapperRect, containerRect);
141
+ let style = _this.calcPosStyle({
142
+ triggerRect,
143
+ wrapperRect,
144
+ containerRect
145
+ });
132
146
 
133
147
  let position = _this.getProp('position');
134
148
 
135
149
  if (_this.getProp('autoAdjustOverflow')) {
136
150
  // console.log('style: ', style, '\ntriggerRect: ', triggerRect, '\nwrapperRect: ', wrapperRect);
137
- const adjustedPos = _this.adjustPosIfNeed(position, style, triggerRect, wrapperRect, containerRect);
151
+ const {
152
+ position: adjustedPos,
153
+ isHeightOverFlow,
154
+ isWidthOverFlow
155
+ } = _this.adjustPosIfNeed(position, style, triggerRect, wrapperRect, containerRect);
138
156
 
139
- if (position !== adjustedPos) {
157
+ if (position !== adjustedPos || isHeightOverFlow || isWidthOverFlow) {
140
158
  position = adjustedPos;
141
- style = _this.calcPosStyle(triggerRect, wrapperRect, containerRect, position);
159
+ style = _this.calcPosStyle({
160
+ triggerRect,
161
+ wrapperRect,
162
+ containerRect,
163
+ position,
164
+ spacing: null,
165
+ isOverFlow: [isHeightOverFlow, isWidthOverFlow]
166
+ });
142
167
  }
143
168
  }
144
169
 
@@ -276,6 +301,29 @@ class Tooltip extends _foundation.default {
276
301
  this._adapter.unregisterResizeHandler(this.onResize);
277
302
  }
278
303
 
304
+ _adjustPos() {
305
+ let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
306
+ let isVertical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
307
+ let adjustType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'reverse';
308
+ let concatPos = arguments.length > 3 ? arguments[3] : undefined;
309
+
310
+ switch (adjustType) {
311
+ case 'reverse':
312
+ return this._reversePos(position, isVertical);
313
+
314
+ case 'expand':
315
+ // only happens when position is top/bottom/left/right
316
+ return this._expandPos(position, concatPos);
317
+
318
+ case 'reduce':
319
+ // only happens when position other than top/bottom/left/right
320
+ return this._reducePos(position);
321
+
322
+ default:
323
+ return this._reversePos(position, isVertical);
324
+ }
325
+ }
326
+
279
327
  _reversePos() {
280
328
  let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
281
329
  let isVertical = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -295,6 +343,19 @@ class Tooltip extends _foundation.default {
295
343
  return position;
296
344
  }
297
345
 
346
+ _expandPos() {
347
+ let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
348
+ let concatPos = arguments.length > 1 ? arguments[1] : undefined;
349
+ return position.concat(concatPos);
350
+ }
351
+
352
+ _reducePos() {
353
+ let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
354
+ // if cur position consists of two directions, remove the last position
355
+ const found = ['Top', 'Bottom', 'Left', 'Right'].find(pos => position.endsWith(pos));
356
+ return found ? position.replace(found, '') : position;
357
+ }
358
+
298
359
  clearDelayTimer() {
299
360
  if (this._timer) {
300
361
  clearTimeout(this._timer);
@@ -455,12 +516,16 @@ class Tooltip extends _foundation.default {
455
516
  return null;
456
517
  }
457
518
 
458
- calcPosStyle(triggerRect, wrapperRect, containerRect, position, spacing) {
459
- triggerRect = ((0, _isEmpty2.default)(triggerRect) ? triggerRect : this._adapter.getTriggerBounding()) || Object.assign({}, defaultRect);
460
- containerRect = ((0, _isEmpty2.default)(containerRect) ? containerRect : this._adapter.getPopupContainerRect()) || Object.assign({}, defaultRect);
461
- wrapperRect = ((0, _isEmpty2.default)(wrapperRect) ? wrapperRect : this._adapter.getWrapperBounding()) || Object.assign({}, defaultRect); // eslint-disable-next-line
519
+ calcPosStyle(props) {
520
+ const {
521
+ spacing,
522
+ isOverFlow
523
+ } = props;
524
+ const triggerRect = ((0, _isEmpty2.default)(props.triggerRect) ? props.triggerRect : this._adapter.getTriggerBounding()) || Object.assign({}, defaultRect);
525
+ const containerRect = ((0, _isEmpty2.default)(props.containerRect) ? props.containerRect : this._adapter.getPopupContainerRect()) || Object.assign({}, defaultRect);
526
+ const wrapperRect = ((0, _isEmpty2.default)(props.wrapperRect) ? props.wrapperRect : this._adapter.getWrapperBounding()) || Object.assign({}, defaultRect); // eslint-disable-next-line
462
527
 
463
- position = position != null ? position : this.getProp('position'); // eslint-disable-next-line
528
+ const position = props.position != null ? props.position : this.getProp('position'); // eslint-disable-next-line
464
529
 
465
530
  const SPACING = spacing != null ? spacing : this.getProp('spacing');
466
531
  const {
@@ -486,79 +551,112 @@ class Tooltip extends _foundation.default {
486
551
  const middleY = triggerRect.top + triggerRect.height / 2;
487
552
  const offsetXWithArrow = positionOffsetX + horizontalArrowWidth / 2;
488
553
  const offsetYWithArrow = positionOffsetY + verticalArrowHeight / 2;
554
+ const heightDifference = wrapperRect.height - containerRect.height;
555
+ const widthDifference = wrapperRect.width - containerRect.width;
556
+ const offsetHeight = heightDifference > 0 ? heightDifference : 0;
557
+ const offsetWidth = widthDifference > 0 ? widthDifference : 0;
558
+ const isHeightOverFlow = isOverFlow && isOverFlow[0];
559
+ const isWidthOverFlow = isOverFlow && isOverFlow[1];
560
+ const isTriggerNearLeft = middleX - containerRect.left < containerRect.right - middleX;
561
+ const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
489
562
 
490
563
  switch (position) {
491
564
  case 'top':
492
- left = middleX;
493
- top = triggerRect.top - SPACING;
565
+ // left = middleX;
566
+ // top = triggerRect.top - SPACING;
567
+ left = isWidthOverFlow ? isTriggerNearLeft ? containerRect.left + wrapperRect.width / 2 : containerRect.right - wrapperRect.width / 2 + offsetWidth : middleX;
568
+ top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
494
569
  translateX = -0.5;
495
570
  translateY = -1;
496
571
  break;
497
572
 
498
573
  case 'topLeft':
499
- left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
500
- top = triggerRect.top - SPACING;
574
+ // left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
575
+ // top = triggerRect.top - SPACING;
576
+ left = isWidthOverFlow ? containerRect.left : pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
577
+ top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
501
578
  translateY = -1;
502
579
  break;
503
580
 
504
581
  case 'topRight':
505
- left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
506
- top = triggerRect.top - SPACING;
582
+ // left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
583
+ // top = triggerRect.top - SPACING;
584
+ left = isWidthOverFlow ? containerRect.right + offsetWidth : pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
585
+ top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
507
586
  translateY = -1;
508
587
  translateX = -1;
509
588
  break;
510
589
 
511
590
  case 'left':
512
- left = triggerRect.left - SPACING;
513
- top = middleY;
591
+ // left = triggerRect.left - SPACING;
592
+ // top = middleY;
593
+ // left = isWidthOverFlow? containerRect.right - SPACING : triggerRect.left - SPACING;
594
+ left = isWidthOverFlow ? containerRect.right + offsetWidth - SPACING + offsetXWithArrow : triggerRect.left - SPACING;
595
+ top = isHeightOverFlow ? isTriggerNearTop ? containerRect.top + wrapperRect.height / 2 : containerRect.bottom - wrapperRect.height / 2 + offsetHeight : middleY;
514
596
  translateX = -1;
515
597
  translateY = -0.5;
516
598
  break;
517
599
 
518
600
  case 'leftTop':
519
- left = triggerRect.left - SPACING;
520
- top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
601
+ // left = triggerRect.left - SPACING;
602
+ // top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
603
+ left = isWidthOverFlow ? containerRect.right + offsetWidth - SPACING + offsetXWithArrow : triggerRect.left - SPACING;
604
+ top = isHeightOverFlow ? containerRect.top : pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
521
605
  translateX = -1;
522
606
  break;
523
607
 
524
608
  case 'leftBottom':
525
- left = triggerRect.left - SPACING;
526
- top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
609
+ // left = triggerRect.left - SPACING;
610
+ // top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
611
+ left = isWidthOverFlow ? containerRect.right + offsetWidth - SPACING + offsetXWithArrow : triggerRect.left - SPACING;
612
+ top = isHeightOverFlow ? containerRect.bottom + offsetHeight : pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
527
613
  translateX = -1;
528
614
  translateY = -1;
529
615
  break;
530
616
 
531
617
  case 'bottom':
532
- left = middleX;
533
- top = triggerRect.top + triggerRect.height + SPACING;
618
+ // left = middleX;
619
+ // top = triggerRect.top + triggerRect.height + SPACING;
620
+ left = isWidthOverFlow ? isTriggerNearLeft ? containerRect.left + wrapperRect.width / 2 : containerRect.right - wrapperRect.width / 2 + offsetWidth : middleX;
621
+ top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
534
622
  translateX = -0.5;
535
623
  break;
536
624
 
537
625
  case 'bottomLeft':
538
- left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
539
- top = triggerRect.bottom + SPACING;
626
+ // left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
627
+ // top = triggerRect.bottom + SPACING;
628
+ left = isWidthOverFlow ? containerRect.left : pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
629
+ top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
540
630
  break;
541
631
 
542
632
  case 'bottomRight':
543
- left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
544
- top = triggerRect.bottom + SPACING;
633
+ // left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
634
+ // top = triggerRect.bottom + SPACING;
635
+ left = isWidthOverFlow ? containerRect.right + offsetWidth : pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
636
+ top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
545
637
  translateX = -1;
546
638
  break;
547
639
 
548
640
  case 'right':
549
- left = triggerRect.right + SPACING;
550
- top = middleY;
641
+ // left = triggerRect.right + SPACING;
642
+ // top = middleY;
643
+ left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
644
+ top = isHeightOverFlow ? isTriggerNearTop ? containerRect.top + wrapperRect.height / 2 : containerRect.bottom - wrapperRect.height / 2 + offsetHeight : middleY;
551
645
  translateY = -0.5;
552
646
  break;
553
647
 
554
648
  case 'rightTop':
555
- left = triggerRect.right + SPACING;
556
- top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
649
+ // left = triggerRect.right + SPACING;
650
+ // top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
651
+ left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
652
+ top = isHeightOverFlow ? containerRect.top : pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
557
653
  break;
558
654
 
559
655
  case 'rightBottom':
560
- left = triggerRect.right + SPACING;
561
- top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
656
+ // left = triggerRect.right + SPACING;
657
+ // top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
658
+ left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
659
+ top = isHeightOverFlow ? containerRect.bottom + offsetHeight : pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
562
660
  translateY = -1;
563
661
  break;
564
662
 
@@ -665,12 +763,53 @@ class Tooltip extends _foundation.default {
665
763
 
666
764
  isLR() {
667
765
  let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
668
- return position.indexOf('left') === 0 || position.indexOf('right') === 0;
766
+ return position.includes('left') || position.includes('right');
669
767
  }
670
768
 
671
769
  isTB() {
672
770
  let position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
673
- return position.indexOf('top') === 0 || position.indexOf('bottom') === 0;
771
+ return position.includes('top') || position.includes('bottom');
772
+ }
773
+
774
+ isReverse(rowSpace, reverseSpace, size) {
775
+ // 原空间不足,反向空间足够
776
+ // Insufficient original space, enough reverse space
777
+ return rowSpace < size && reverseSpace > size;
778
+ }
779
+
780
+ isOverFlow(rowSpace, reverseSpace, size) {
781
+ // 原空间且反向空间都不足
782
+ // The original space and the reverse space are not enough
783
+ return rowSpace < size && reverseSpace < size;
784
+ }
785
+
786
+ isHalfOverFlow(posSpace, negSpace, size) {
787
+ // 正半空间或者负半空间不足,即表示有遮挡,需要偏移
788
+ // Insufficient positive half space or negative half space means that there is occlusion and needs to be offset
789
+ return posSpace < size || negSpace < size;
790
+ }
791
+
792
+ isHalfAllEnough(posSpace, negSpace, size) {
793
+ // 正半空间和负半空间都足够,即表示可以从 topLeft/topRight 变成 top
794
+ // Both positive and negative half-spaces are sufficient, which means you can change from topLeft/topRight to top
795
+ return posSpace >= size || negSpace >= size;
796
+ }
797
+
798
+ getReverse(viewOverFlow, containerOverFlow, shouldReverseView, shouldReverseContainer) {
799
+ /**
800
+ * 基于视口和容器一起判断,以下几种情况允许从原方向转到反方向,以判断是否应该由top->bottom为例子
801
+ *
802
+ * 1. 视口上下空间不足 且 容器上空间❌下空间✅
803
+ * 2. 视口上空间❌下空间✅ 且 容器上下空间不足
804
+ * 3. 视口上空间❌下空间✅ 且 容器上空间❌下空间✅
805
+ *
806
+ * Based on the judgment of the viewport and the container, the following situations are allowed to turn from the original direction to the opposite direction
807
+ * to judge whether it should be top->bottom as an example
808
+ * 1. There is insufficient space above and below the viewport and the space above the container ❌ the space below ✅
809
+ * 2. The space above the viewport ❌ the space below ✅ and the space above and below the container is insufficient
810
+ * 3. Viewport upper space ❌ lower space✅ and container upper space ❌ lower space✅
811
+ */
812
+ return viewOverFlow && shouldReverseContainer || shouldReverseView && containerOverFlow || shouldReverseView && shouldReverseContainer;
674
813
  } // place the dom correctly
675
814
 
676
815
 
@@ -680,8 +819,15 @@ class Tooltip extends _foundation.default {
680
819
  innerHeight
681
820
  } = window;
682
821
  const {
683
- spacing
822
+ spacing,
823
+ margin
684
824
  } = this.getProps();
825
+ const marginLeft = typeof margin === 'number' ? margin : margin.marginLeft;
826
+ const marginTop = typeof margin === 'number' ? margin : margin.marginTop;
827
+ const marginRight = typeof margin === 'number' ? margin : margin.marginRight;
828
+ const marginBottom = typeof margin === 'number' ? margin : margin.marginBottom;
829
+ let isHeightOverFlow = false;
830
+ let isWidthOverFlow = false;
685
831
 
686
832
  if (wrapperRect.width > 0 && wrapperRect.height > 0) {
687
833
  // let clientLeft = left + translateX * wrapperRect.width - containerRect.scrollLeft;
@@ -704,187 +850,324 @@ class Tooltip extends _foundation.default {
704
850
  const restClientBottom = innerHeight - clientBottom;
705
851
  const widthIsBigger = wrapperRect.width > triggerRect.width;
706
852
  const heightIsBigger = wrapperRect.height > triggerRect.height; // The wrapperR ect.top|bottom equivalent cannot be directly used here for comparison, which is easy to cause jitter
707
-
708
- const shouldReverseTop = clientTop < wrapperRect.height + spacing && restClientBottom > wrapperRect.height + spacing;
709
- const shouldReverseLeft = clientLeft < wrapperRect.width + spacing && restClientRight > wrapperRect.width + spacing;
710
- const shouldReverseBottom = restClientBottom < wrapperRect.height + spacing && clientTop > wrapperRect.height + spacing;
711
- const shouldReverseRight = restClientRight < wrapperRect.width + spacing && clientLeft > wrapperRect.width + spacing;
853
+ // 基于视口的微调判断
854
+ // Fine-tuning judgment based on viewport
855
+
856
+ const shouldViewReverseTop = clientTop - marginTop < wrapperRect.height + spacing && restClientBottom - marginBottom > wrapperRect.height + spacing;
857
+ const shouldViewReverseLeft = clientLeft - marginLeft < wrapperRect.width + spacing && restClientRight - marginRight > wrapperRect.width + spacing;
858
+ const shouldViewReverseBottom = restClientBottom - marginBottom < wrapperRect.height + spacing && clientTop - marginTop > wrapperRect.height + spacing;
859
+ const shouldViewReverseRight = restClientRight - marginRight < wrapperRect.width + spacing && clientLeft - marginLeft > wrapperRect.width + spacing;
860
+ const shouldViewReverseTopOver = restClientTop - marginBottom < wrapperRect.height + spacing && clientBottom - marginTop > wrapperRect.height + spacing;
861
+ const shouldViewReverseBottomOver = clientBottom - marginTop < wrapperRect.height + spacing && restClientTop - marginBottom > wrapperRect.height + spacing;
862
+ const shouldViewReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
863
+ const shouldViewReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
864
+ const shouldViewReverseLeftSide = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
865
+ const shouldViewReverseRightSide = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
712
866
  const shouldReverseTopOver = restClientTop < wrapperRect.height + spacing && clientBottom > wrapperRect.height + spacing;
713
867
  const shouldReverseBottomOver = clientBottom < wrapperRect.height + spacing && restClientTop > wrapperRect.height + spacing;
714
- const shouldReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
715
- const shouldReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
716
- const shouldReverseLeftSide = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
717
- const shouldReverseRightSide = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
718
868
  const shouldReverseLeftOver = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
719
- const shouldReverseRightOver = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
869
+ const shouldReverseRightOver = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width; // 基于容器的微调判断
870
+ // Fine-tuning judgment based on container
871
+
872
+ const clientTopInContainer = clientTop - containerRect.top;
873
+ const clientLeftInContainer = clientLeft - containerRect.left;
874
+ const clientBottomInContainer = clientTopInContainer + triggerRect.height;
875
+ const clientRightInContainer = clientLeftInContainer + triggerRect.width;
876
+ const restClientBottomInContainer = containerRect.bottom - clientBottom;
877
+ const restClientRightInContainer = containerRect.right - clientRight;
878
+ const restClientTopInContainer = restClientBottomInContainer + triggerRect.height;
879
+ const restClientLeftInContainer = restClientRightInContainer + triggerRect.width; // 当原空间不足,反向空间足够时,可以反向。
880
+ // When the original space is insufficient and the reverse space is sufficient, the reverse can be performed.
881
+
882
+ const shouldContainerReverseTop = this.isReverse(clientTopInContainer - marginTop, restClientBottomInContainer - marginBottom, wrapperRect.height + spacing);
883
+ const shouldContainerReverseLeft = this.isReverse(clientLeftInContainer - marginLeft, restClientRightInContainer - marginRight, wrapperRect.width + spacing);
884
+ const shouldContainerReverseBottom = this.isReverse(restClientBottomInContainer - marginBottom, clientTopInContainer - marginTop, wrapperRect.height + spacing);
885
+ const shouldContainerReverseRight = this.isReverse(restClientRightInContainer - marginRight, clientLeftInContainer - marginLeft, wrapperRect.width + spacing);
886
+ const shouldContainerReverseTopOver = this.isReverse(restClientTopInContainer - marginBottom, clientBottomInContainer - marginTop, wrapperRect.height + spacing);
887
+ const shouldContainerReverseBottomOver = this.isReverse(clientBottomInContainer - marginTop, restClientTopInContainer - marginBottom, wrapperRect.height + spacing);
888
+ const shouldContainerReverseTopSide = this.isReverse(restClientTopInContainer, clientBottomInContainer, wrapperRect.height);
889
+ const shouldContainerReverseBottomSide = this.isReverse(clientBottomInContainer, restClientTopInContainer, wrapperRect.height);
890
+ const shouldContainerReverseLeftSide = this.isReverse(restClientLeftInContainer, clientRightInContainer, wrapperRect.width);
891
+ const shouldContainerReverseRightSide = this.isReverse(clientRightInContainer, restClientLeftInContainer, wrapperRect.width);
892
+ const halfHeight = triggerRect.height / 2;
893
+ const halfWidth = triggerRect.width / 2; // 视口, 原空间与反向空间是否都不足判断
894
+ // Viewport, whether the original space and the reverse space are insufficient to judge
895
+
896
+ const isViewYOverFlow = this.isOverFlow(clientTop - marginTop, restClientBottom - marginBottom, wrapperRect.height + spacing);
897
+ const isViewXOverFlow = this.isOverFlow(clientLeft - marginLeft, restClientRight - marginRight, wrapperRect.width + spacing);
898
+ const isViewYOverFlowSide = this.isOverFlow(clientBottom - marginTop, restClientTop - marginBottom, wrapperRect.height + spacing);
899
+ const isViewXOverFlowSide = this.isOverFlow(clientRight - marginLeft, restClientLeft - marginRight, wrapperRect.width + spacing);
900
+ const isViewYOverFlowSideHalf = this.isHalfOverFlow(clientBottom - halfHeight, restClientTop - halfHeight, wrapperRect.height / 2);
901
+ const isViewXOverFlowSideHalf = this.isHalfOverFlow(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2);
902
+ const isViewYEnoughSideHalf = this.isHalfAllEnough(clientBottom - halfHeight, restClientTop - halfHeight, wrapperRect.height / 2);
903
+ const isViewXEnoughSideHalf = this.isHalfAllEnough(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2); // 容器, 原空间与反向空间是否都不足判断
904
+ // container, whether the original space and the reverse space are insufficient to judge
905
+
906
+ const isContainerYOverFlow = this.isOverFlow(clientTopInContainer - marginTop, restClientBottomInContainer - marginBottom, wrapperRect.height + spacing);
907
+ const isContainerXOverFlow = this.isOverFlow(clientLeftInContainer - marginLeft, restClientRightInContainer - marginRight, wrapperRect.width + spacing);
908
+ const isContainerYOverFlowSide = this.isOverFlow(clientBottomInContainer - marginTop, restClientTopInContainer - marginBottom, wrapperRect.height + spacing);
909
+ const isContainerXOverFlowSide = this.isOverFlow(clientRightInContainer - marginLeft, restClientLeftInContainer - marginRight, wrapperRect.width + spacing);
910
+ const isContainerYOverFlowSideHalf = this.isHalfOverFlow(clientBottomInContainer - halfHeight, restClientTopInContainer - halfHeight, wrapperRect.height / 2);
911
+ const isContainerXOverFlowSideHalf = this.isHalfOverFlow(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2);
912
+ const isContainerYEnoughSideHalf = this.isHalfAllEnough(clientBottomInContainer - halfHeight, restClientTopInContainer - halfHeight, wrapperRect.height / 2);
913
+ const isContainerXEnoughSideHalf = this.isHalfAllEnough(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2); // 综合 viewport + container 判断微调,即视口 + 容器都放置不行时才能考虑位置调整
914
+ // Comprehensive viewport + container judgment fine-tuning, that is, the position adjustment can only be considered when the viewport + container cannot be placed.
915
+
916
+ const shouldReverseTop = this.getReverse(isViewYOverFlow, isContainerYOverFlow, shouldViewReverseTop, shouldContainerReverseTop);
917
+ const shouldReverseLeft = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseLeft, shouldContainerReverseLeft);
918
+ const shouldReverseBottom = this.getReverse(isViewYOverFlow, isContainerYOverFlow, shouldViewReverseBottom, shouldContainerReverseBottom);
919
+ const shouldReverseRight = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseRight, shouldContainerReverseRight); // const shouldReverseTopOver = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseTopOver, shouldContainerReverseTopOver);
920
+ // const shouldReverseBottomOver = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseBottomOver, shouldContainerReverseBottomOver);
921
+
922
+ const shouldReverseTopSide = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseTopSide, shouldContainerReverseTopSide);
923
+ const shouldReverseBottomSide = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseBottomSide, shouldContainerReverseBottomSide);
924
+ const shouldReverseLeftSide = this.getReverse(isViewXOverFlowSide, isContainerXOverFlowSide, shouldViewReverseLeftSide, shouldContainerReverseLeftSide);
925
+ const shouldReverseRightSide = this.getReverse(isViewXOverFlowSide, isContainerXOverFlowSide, shouldViewReverseRightSide, shouldContainerReverseRightSide);
926
+ const isYOverFlowSideHalf = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
927
+ const isXOverFlowSideHalf = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
720
928
 
721
929
  switch (position) {
722
930
  case 'top':
723
931
  if (shouldReverseTop) {
724
- position = this._reversePos(position, true);
932
+ position = this._adjustPos(position, true);
933
+ }
934
+
935
+ if (isXOverFlowSideHalf && (shouldReverseLeftSide || shouldReverseRightSide)) {
936
+ position = this._adjustPos(position, true, 'expand', shouldReverseLeftSide ? 'Right' : 'Left');
725
937
  }
726
938
 
727
939
  break;
728
940
 
729
941
  case 'topLeft':
730
942
  if (shouldReverseTop) {
731
- position = this._reversePos(position, true);
943
+ position = this._adjustPos(position, true);
732
944
  }
733
945
 
734
946
  if (shouldReverseLeftSide && widthIsBigger) {
735
- position = this._reversePos(position);
947
+ position = this._adjustPos(position, true);
948
+ }
949
+
950
+ if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
951
+ position = this._adjustPos(position, true, 'reduce');
736
952
  }
737
953
 
738
954
  break;
739
955
 
740
956
  case 'topRight':
741
957
  if (shouldReverseTop) {
742
- position = this._reversePos(position, true);
958
+ position = this._adjustPos(position, true);
743
959
  }
744
960
 
745
961
  if (shouldReverseRightSide && widthIsBigger) {
746
- position = this._reversePos(position);
962
+ position = this._adjustPos(position);
963
+ }
964
+
965
+ if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
966
+ position = this._adjustPos(position, true, 'reduce');
747
967
  }
748
968
 
749
969
  break;
750
970
 
751
971
  case 'left':
752
972
  if (shouldReverseLeft) {
753
- position = this._reversePos(position);
973
+ position = this._adjustPos(position);
974
+ }
975
+
976
+ if (isYOverFlowSideHalf && (shouldReverseTopSide || shouldReverseBottomSide)) {
977
+ position = this._adjustPos(position, false, 'expand', shouldReverseTopSide ? 'Bottom' : 'Top');
754
978
  }
755
979
 
756
980
  break;
757
981
 
758
982
  case 'leftTop':
759
983
  if (shouldReverseLeft) {
760
- position = this._reversePos(position);
984
+ position = this._adjustPos(position);
761
985
  }
762
986
 
763
987
  if (shouldReverseTopSide && heightIsBigger) {
764
- position = this._reversePos(position, true);
988
+ position = this._adjustPos(position, true);
989
+ }
990
+
991
+ if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
992
+ position = this._adjustPos(position, false, 'reduce');
765
993
  }
766
994
 
767
995
  break;
768
996
 
769
997
  case 'leftBottom':
770
998
  if (shouldReverseLeft) {
771
- position = this._reversePos(position);
999
+ position = this._adjustPos(position);
772
1000
  }
773
1001
 
774
1002
  if (shouldReverseBottomSide && heightIsBigger) {
775
- position = this._reversePos(position, true);
1003
+ position = this._adjustPos(position, true);
1004
+ }
1005
+
1006
+ if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
1007
+ position = this._adjustPos(position, false, 'reduce');
776
1008
  }
777
1009
 
778
1010
  break;
779
1011
 
780
1012
  case 'bottom':
781
1013
  if (shouldReverseBottom) {
782
- position = this._reversePos(position, true);
1014
+ position = this._adjustPos(position, true);
1015
+ }
1016
+
1017
+ if (isXOverFlowSideHalf && (shouldReverseLeftSide || shouldReverseRightSide)) {
1018
+ position = this._adjustPos(position, true, 'expand', shouldReverseLeftSide ? 'Right' : 'Left');
783
1019
  }
784
1020
 
785
1021
  break;
786
1022
 
787
1023
  case 'bottomLeft':
788
1024
  if (shouldReverseBottom) {
789
- position = this._reversePos(position, true);
1025
+ position = this._adjustPos(position, true);
790
1026
  }
791
1027
 
792
1028
  if (shouldReverseLeftSide && widthIsBigger) {
793
- position = this._reversePos(position);
1029
+ position = this._adjustPos(position);
1030
+ }
1031
+
1032
+ if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
1033
+ position = this._adjustPos(position, true, 'reduce');
794
1034
  }
795
1035
 
796
1036
  break;
797
1037
 
798
1038
  case 'bottomRight':
799
1039
  if (shouldReverseBottom) {
800
- position = this._reversePos(position, true);
1040
+ position = this._adjustPos(position, true);
801
1041
  }
802
1042
 
803
1043
  if (shouldReverseRightSide && widthIsBigger) {
804
- position = this._reversePos(position);
1044
+ position = this._adjustPos(position);
1045
+ }
1046
+
1047
+ if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
1048
+ position = this._adjustPos(position, true, 'reduce');
805
1049
  }
806
1050
 
807
1051
  break;
808
1052
 
809
1053
  case 'right':
810
1054
  if (shouldReverseRight) {
811
- position = this._reversePos(position);
1055
+ position = this._adjustPos(position);
1056
+ }
1057
+
1058
+ if (isYOverFlowSideHalf && (shouldReverseTopSide || shouldReverseBottomSide)) {
1059
+ position = this._adjustPos(position, false, 'expand', shouldReverseTopSide ? 'Bottom' : 'Top');
812
1060
  }
813
1061
 
814
1062
  break;
815
1063
 
816
1064
  case 'rightTop':
817
1065
  if (shouldReverseRight) {
818
- position = this._reversePos(position);
1066
+ position = this._adjustPos(position);
819
1067
  }
820
1068
 
821
1069
  if (shouldReverseTopSide && heightIsBigger) {
822
- position = this._reversePos(position, true);
1070
+ position = this._adjustPos(position, true);
1071
+ }
1072
+
1073
+ if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
1074
+ position = this._adjustPos(position, false, 'reduce');
823
1075
  }
824
1076
 
825
1077
  break;
826
1078
 
827
1079
  case 'rightBottom':
828
1080
  if (shouldReverseRight) {
829
- position = this._reversePos(position);
1081
+ position = this._adjustPos(position);
830
1082
  }
831
1083
 
832
1084
  if (shouldReverseBottomSide && heightIsBigger) {
833
- position = this._reversePos(position, true);
1085
+ position = this._adjustPos(position, true);
1086
+ }
1087
+
1088
+ if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
1089
+ position = this._adjustPos(position, false, 'reduce');
834
1090
  }
835
1091
 
836
1092
  break;
837
1093
 
838
1094
  case 'leftTopOver':
839
1095
  if (shouldReverseTopOver) {
840
- position = this._reversePos(position, true);
1096
+ position = this._adjustPos(position, true);
841
1097
  }
842
1098
 
843
1099
  if (shouldReverseLeftOver) {
844
- position = this._reversePos(position);
1100
+ position = this._adjustPos(position);
845
1101
  }
846
1102
 
847
1103
  break;
848
1104
 
849
1105
  case 'leftBottomOver':
850
1106
  if (shouldReverseBottomOver) {
851
- position = this._reversePos(position, true);
1107
+ position = this._adjustPos(position, true);
852
1108
  }
853
1109
 
854
1110
  if (shouldReverseLeftOver) {
855
- position = this._reversePos(position);
1111
+ position = this._adjustPos(position);
856
1112
  }
857
1113
 
858
1114
  break;
859
1115
 
860
1116
  case 'rightTopOver':
861
1117
  if (shouldReverseTopOver) {
862
- position = this._reversePos(position, true);
1118
+ position = this._adjustPos(position, true);
863
1119
  }
864
1120
 
865
1121
  if (shouldReverseRightOver) {
866
- position = this._reversePos(position);
1122
+ position = this._adjustPos(position);
867
1123
  }
868
1124
 
869
1125
  break;
870
1126
 
871
1127
  case 'rightBottomOver':
872
1128
  if (shouldReverseBottomOver) {
873
- position = this._reversePos(position, true);
1129
+ position = this._adjustPos(position, true);
874
1130
  }
875
1131
 
876
1132
  if (shouldReverseRightOver) {
877
- position = this._reversePos(position);
1133
+ position = this._adjustPos(position);
878
1134
  }
879
1135
 
880
1136
  break;
881
1137
 
882
1138
  default:
883
1139
  break;
1140
+ } // 判断溢出 Judgment overflow
1141
+ // 上下方向 top and bottom
1142
+
1143
+
1144
+ if (this.isTB(position)) {
1145
+ isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
1146
+
1147
+ if (position === 'top' || position === 'bottom') {
1148
+ isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
1149
+ } else {
1150
+ isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide;
1151
+ }
1152
+ } // 左右方向 left and right
1153
+
1154
+
1155
+ if (this.isLR(position)) {
1156
+ isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
1157
+
1158
+ if (position === 'left' || position === 'right') {
1159
+ isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
1160
+ } else {
1161
+ isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide;
1162
+ }
884
1163
  }
885
1164
  }
886
1165
 
887
- return position;
1166
+ return {
1167
+ position,
1168
+ isHeightOverFlow,
1169
+ isWidthOverFlow
1170
+ };
888
1171
  }
889
1172
 
890
1173
  _bindScrollEvent() {