@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.
- package/anchor/animation.scss +2 -2
- package/autoComplete/animation.scss +2 -2
- package/breadcrumb/animation.scss +2 -2
- package/button/animation.scss +26 -26
- package/carousel/animation.scss +2 -2
- package/cascader/animation.scss +2 -2
- package/cascader/cascader.scss +15 -0
- package/cascader/variables.scss +1 -0
- package/checkbox/animation.scss +4 -4
- package/checkbox/variables.scss +1 -1
- package/collapsible/animation.scss +2 -2
- package/datePicker/animation.scss +2 -2
- package/dropdown/animation.scss +1 -1
- package/dropdown/foundation.ts +16 -9
- package/dropdown/menuFoundation.ts +1 -12
- package/form/form.scss +3 -4
- package/form/rtl.scss +0 -1
- package/form/variables.scss +38 -35
- package/input/animation.scss +6 -6
- package/inputNumber/animation.scss +4 -4
- package/lib/cjs/anchor/anchor.css +1 -1
- package/lib/cjs/anchor/animation.scss +2 -2
- package/lib/cjs/autoComplete/animation.scss +2 -2
- package/lib/cjs/autoComplete/autoComplete.css +1 -1
- package/lib/cjs/breadcrumb/animation.scss +2 -2
- package/lib/cjs/breadcrumb/breadcrumb.css +1 -1
- package/lib/cjs/button/animation.scss +26 -26
- package/lib/cjs/button/button.css +7 -7
- package/lib/cjs/carousel/animation.scss +2 -2
- package/lib/cjs/carousel/carousel.css +6 -6
- package/lib/cjs/cascader/animation.scss +2 -2
- package/lib/cjs/cascader/cascader.css +13 -1
- package/lib/cjs/cascader/cascader.scss +15 -0
- package/lib/cjs/cascader/variables.scss +1 -0
- package/lib/cjs/checkbox/animation.scss +4 -4
- package/lib/cjs/checkbox/checkbox.css +2 -2
- package/lib/cjs/checkbox/variables.scss +1 -1
- package/lib/cjs/collapsible/animation.scss +2 -2
- package/lib/cjs/collapsible/collapsible.css +1 -1
- package/lib/cjs/datePicker/animation.scss +2 -2
- package/lib/cjs/dropdown/animation.scss +1 -1
- package/lib/cjs/dropdown/dropdown.css +1 -1
- package/lib/cjs/dropdown/foundation.d.ts +4 -3
- package/lib/cjs/dropdown/foundation.js +21 -8
- package/lib/cjs/dropdown/menuFoundation.d.ts +0 -1
- package/lib/cjs/dropdown/menuFoundation.js +0 -11
- package/lib/cjs/form/form.css +0 -2
- package/lib/cjs/form/form.scss +3 -4
- package/lib/cjs/form/rtl.scss +0 -1
- package/lib/cjs/form/variables.scss +38 -35
- package/lib/cjs/input/animation.scss +6 -6
- package/lib/cjs/input/input.css +2 -2
- package/lib/cjs/input/textarea.css +1 -1
- package/lib/cjs/inputNumber/animation.scss +4 -4
- package/lib/cjs/inputNumber/inputNumber.css +1 -1
- package/lib/cjs/navigation/animation.scss +2 -2
- package/lib/cjs/navigation/navigation.css +1 -1
- package/lib/cjs/pagination/animation.scss +4 -4
- package/lib/cjs/pagination/pagination.css +1 -1
- package/lib/cjs/radio/animation.scss +4 -4
- package/lib/cjs/radio/radio.css +4 -4
- package/lib/cjs/rating/animation.scss +2 -2
- package/lib/cjs/rating/rating.css +1 -1
- package/lib/cjs/scrollList/animation.scss +1 -1
- package/lib/cjs/scrollList/scrollList.css +1 -1
- package/lib/cjs/select/animation.scss +6 -6
- package/lib/cjs/select/select.css +2 -2
- package/lib/cjs/slider/animation.scss +2 -2
- package/lib/cjs/slider/slider.css +1 -1
- package/lib/cjs/steps/animation.scss +6 -6
- package/lib/cjs/steps/steps.css +7 -7
- package/lib/cjs/switch/animation.scss +1 -1
- package/lib/cjs/switch/switch.css +1 -1
- package/lib/cjs/table/animation.scss +1 -1
- package/lib/cjs/table/table.css +2 -2
- package/lib/cjs/tabs/animation.scss +8 -8
- package/lib/cjs/tabs/tabs.css +46 -6
- package/lib/cjs/tabs/tabs.scss +43 -2
- package/lib/cjs/tabs/variables.scss +20 -0
- package/lib/cjs/tagInput/animation.scss +4 -4
- package/lib/cjs/tagInput/tagInput.css +1 -1
- package/lib/cjs/timePicker/utils/animation.scss +4 -4
- package/lib/cjs/tooltip/constants.d.ts +1 -0
- package/lib/cjs/tooltip/constants.js +2 -2
- package/lib/cjs/tooltip/foundation.d.ts +21 -2
- package/lib/cjs/tooltip/foundation.js +360 -77
- package/lib/cjs/transfer/animation.scss +2 -2
- package/lib/cjs/transfer/transfer.css +1 -1
- package/lib/cjs/tree/animation.scss +2 -2
- package/lib/cjs/tree/tree.css +1 -1
- package/lib/es/anchor/anchor.css +1 -1
- package/lib/es/anchor/animation.scss +2 -2
- package/lib/es/autoComplete/animation.scss +2 -2
- package/lib/es/autoComplete/autoComplete.css +1 -1
- package/lib/es/breadcrumb/animation.scss +2 -2
- package/lib/es/breadcrumb/breadcrumb.css +1 -1
- package/lib/es/button/animation.scss +26 -26
- package/lib/es/button/button.css +7 -7
- package/lib/es/carousel/animation.scss +2 -2
- package/lib/es/carousel/carousel.css +6 -6
- package/lib/es/cascader/animation.scss +2 -2
- package/lib/es/cascader/cascader.css +13 -1
- package/lib/es/cascader/cascader.scss +15 -0
- package/lib/es/cascader/variables.scss +1 -0
- package/lib/es/checkbox/animation.scss +4 -4
- package/lib/es/checkbox/checkbox.css +2 -2
- package/lib/es/checkbox/variables.scss +1 -1
- package/lib/es/collapsible/animation.scss +2 -2
- package/lib/es/collapsible/collapsible.css +1 -1
- package/lib/es/datePicker/animation.scss +2 -2
- package/lib/es/dropdown/animation.scss +1 -1
- package/lib/es/dropdown/dropdown.css +1 -1
- package/lib/es/dropdown/foundation.d.ts +4 -3
- package/lib/es/dropdown/foundation.js +21 -8
- package/lib/es/dropdown/menuFoundation.d.ts +0 -1
- package/lib/es/dropdown/menuFoundation.js +1 -12
- package/lib/es/form/form.css +0 -2
- package/lib/es/form/form.scss +3 -4
- package/lib/es/form/rtl.scss +0 -1
- package/lib/es/form/variables.scss +38 -35
- package/lib/es/input/animation.scss +6 -6
- package/lib/es/input/input.css +2 -2
- package/lib/es/input/textarea.css +1 -1
- package/lib/es/inputNumber/animation.scss +4 -4
- package/lib/es/inputNumber/inputNumber.css +1 -1
- package/lib/es/navigation/animation.scss +2 -2
- package/lib/es/navigation/navigation.css +1 -1
- package/lib/es/pagination/animation.scss +4 -4
- package/lib/es/pagination/pagination.css +1 -1
- package/lib/es/radio/animation.scss +4 -4
- package/lib/es/radio/radio.css +4 -4
- package/lib/es/rating/animation.scss +2 -2
- package/lib/es/rating/rating.css +1 -1
- package/lib/es/scrollList/animation.scss +1 -1
- package/lib/es/scrollList/scrollList.css +1 -1
- package/lib/es/select/animation.scss +6 -6
- package/lib/es/select/select.css +2 -2
- package/lib/es/slider/animation.scss +2 -2
- package/lib/es/slider/slider.css +1 -1
- package/lib/es/steps/animation.scss +6 -6
- package/lib/es/steps/steps.css +7 -7
- package/lib/es/switch/animation.scss +1 -1
- package/lib/es/switch/switch.css +1 -1
- package/lib/es/table/animation.scss +1 -1
- package/lib/es/table/table.css +2 -2
- package/lib/es/tabs/animation.scss +8 -8
- package/lib/es/tabs/tabs.css +46 -6
- package/lib/es/tabs/tabs.scss +43 -2
- package/lib/es/tabs/variables.scss +20 -0
- package/lib/es/tagInput/animation.scss +4 -4
- package/lib/es/tagInput/tagInput.css +1 -1
- package/lib/es/timePicker/utils/animation.scss +4 -4
- package/lib/es/tooltip/constants.d.ts +1 -0
- package/lib/es/tooltip/constants.js +2 -2
- package/lib/es/tooltip/foundation.d.ts +21 -2
- package/lib/es/tooltip/foundation.js +360 -77
- package/lib/es/transfer/animation.scss +2 -2
- package/lib/es/transfer/transfer.css +1 -1
- package/lib/es/tree/animation.scss +2 -2
- package/lib/es/tree/tree.css +1 -1
- package/navigation/animation.scss +2 -2
- package/package.json +2 -2
- package/pagination/animation.scss +4 -4
- package/radio/animation.scss +4 -4
- package/rating/animation.scss +2 -2
- package/scrollList/animation.scss +1 -1
- package/select/animation.scss +6 -6
- package/slider/animation.scss +2 -2
- package/steps/animation.scss +6 -6
- package/switch/animation.scss +1 -1
- package/table/animation.scss +1 -1
- package/tabs/animation.scss +8 -8
- package/tabs/tabs.scss +43 -2
- package/tabs/variables.scss +20 -0
- package/tagInput/animation.scss +4 -4
- package/timePicker/utils/animation.scss +4 -4
- package/tooltip/constants.ts +1 -0
- package/tooltip/foundation.ts +322 -78
- package/transfer/animation.scss +2 -2
- package/tree/animation.scss +2 -2
package/tooltip/foundation.ts
CHANGED
|
@@ -133,11 +133,26 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
133
133
|
unBindResizeEvent() {
|
|
134
134
|
this._adapter.unregisterResizeHandler(this.onResize);
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
removePortal = () => {
|
|
138
138
|
this._adapter.removePortal();
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
_adjustPos(position = '', isVertical = false, adjustType = 'reverse', concatPos?: any) {
|
|
142
|
+
switch (adjustType) {
|
|
143
|
+
case 'reverse':
|
|
144
|
+
return this._reversePos(position, isVertical);
|
|
145
|
+
case 'expand':
|
|
146
|
+
// only happens when position is top/bottom/left/right
|
|
147
|
+
return this._expandPos(position, concatPos);
|
|
148
|
+
case 'reduce':
|
|
149
|
+
// only happens when position other than top/bottom/left/right
|
|
150
|
+
return this._reducePos(position);
|
|
151
|
+
default:
|
|
152
|
+
return this._reversePos(position, isVertical);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
141
156
|
_reversePos(position = '', isVertical = false) {
|
|
142
157
|
if (isVertical) {
|
|
143
158
|
if (REGS.TOP.test(position)) {
|
|
@@ -153,6 +168,16 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
153
168
|
return position;
|
|
154
169
|
}
|
|
155
170
|
|
|
171
|
+
_expandPos(position = '', concatPos: string) {
|
|
172
|
+
return position.concat(concatPos);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_reducePos(position = '') {
|
|
176
|
+
// if cur position consists of two directions, remove the last position
|
|
177
|
+
const found = ['Top', 'Bottom', 'Left', 'Right'].find(pos => position.endsWith(pos));
|
|
178
|
+
return found ? position.replace(found, ''): position;
|
|
179
|
+
}
|
|
180
|
+
|
|
156
181
|
clearDelayTimer() {
|
|
157
182
|
if (this._timer) {
|
|
158
183
|
clearTimeout(this._timer);
|
|
@@ -269,6 +294,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
269
294
|
const content = this.getProp('content');
|
|
270
295
|
const trigger = this.getProp('trigger');
|
|
271
296
|
const clickTriggerToHide = this.getProp('clickTriggerToHide');
|
|
297
|
+
const { visible } = this.getStates();
|
|
298
|
+
if (visible) {
|
|
299
|
+
return ;
|
|
300
|
+
}
|
|
272
301
|
|
|
273
302
|
this.clearDelayTimer();
|
|
274
303
|
|
|
@@ -285,9 +314,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
285
314
|
this._togglePortalVisible(true);
|
|
286
315
|
});
|
|
287
316
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this._adapter.insertPortal(content, position);
|
|
317
|
+
this._adapter.insertPortal(content, { left: -9999, top: -9999 }); // offscreen rendering
|
|
291
318
|
|
|
292
319
|
if (trigger === 'custom') {
|
|
293
320
|
// eslint-disable-next-line
|
|
@@ -358,14 +385,15 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
358
385
|
return null;
|
|
359
386
|
}
|
|
360
387
|
|
|
361
|
-
calcPosStyle(triggerRect: DOMRect
|
|
362
|
-
|
|
363
|
-
|
|
388
|
+
calcPosStyle(props: {triggerRect: DOMRect; wrapperRect: DOMRect; containerRect: PopupContainerDOMRect; position?: Position; spacing?: number; isOverFlow?: [boolean, boolean]}) {
|
|
389
|
+
const { spacing, isOverFlow } = props;
|
|
390
|
+
const triggerRect = (isEmpty(props.triggerRect) ? props.triggerRect : this._adapter.getTriggerBounding()) || { ...defaultRect as any };
|
|
391
|
+
const containerRect = (isEmpty(props.containerRect) ? props.containerRect : this._adapter.getPopupContainerRect()) || {
|
|
364
392
|
...defaultRect,
|
|
365
393
|
};
|
|
366
|
-
wrapperRect = (isEmpty(wrapperRect) ? wrapperRect : this._adapter.getWrapperBounding()) || { ...defaultRect as any };
|
|
394
|
+
const wrapperRect = (isEmpty(props.wrapperRect) ? props.wrapperRect : this._adapter.getWrapperBounding()) || { ...defaultRect as any };
|
|
367
395
|
// eslint-disable-next-line
|
|
368
|
-
position = position != null ? position : this.getProp('position');
|
|
396
|
+
const position = props.position != null ? props.position : this.getProp('position');
|
|
369
397
|
// eslint-disable-next-line
|
|
370
398
|
const SPACING = spacing != null ? spacing : this.getProp('spacing');
|
|
371
399
|
const { arrowPointAtCenter, showArrow, arrowBounding } = this.getProps();
|
|
@@ -389,67 +417,104 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
389
417
|
const offsetXWithArrow = positionOffsetX + horizontalArrowWidth / 2;
|
|
390
418
|
const offsetYWithArrow = positionOffsetY + verticalArrowHeight / 2;
|
|
391
419
|
|
|
420
|
+
const heightDifference = wrapperRect.height - containerRect.height;
|
|
421
|
+
const widthDifference = wrapperRect.width - containerRect.width;
|
|
422
|
+
|
|
423
|
+
const offsetHeight = heightDifference > 0 ? heightDifference : 0;
|
|
424
|
+
const offsetWidth = widthDifference > 0 ? widthDifference : 0;
|
|
425
|
+
const isHeightOverFlow = isOverFlow && isOverFlow[0];
|
|
426
|
+
const isWidthOverFlow = isOverFlow && isOverFlow[1];
|
|
427
|
+
|
|
428
|
+
const isTriggerNearLeft = middleX - containerRect.left < containerRect.right - middleX;
|
|
429
|
+
const isTriggerNearTop = middleY - containerRect.top < containerRect.bottom - middleY;
|
|
430
|
+
|
|
431
|
+
|
|
392
432
|
switch (position) {
|
|
393
433
|
case 'top':
|
|
394
|
-
left = middleX;
|
|
395
|
-
top = triggerRect.top - SPACING;
|
|
434
|
+
// left = middleX;
|
|
435
|
+
// top = triggerRect.top - SPACING;
|
|
436
|
+
left = isWidthOverFlow ? (isTriggerNearLeft ? containerRect.left + wrapperRect.width / 2 : containerRect.right - wrapperRect.width / 2 + offsetWidth): middleX;
|
|
437
|
+
top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
|
|
396
438
|
translateX = -0.5;
|
|
397
439
|
translateY = -1;
|
|
398
440
|
break;
|
|
399
441
|
case 'topLeft':
|
|
400
|
-
left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
401
|
-
top = triggerRect.top - SPACING;
|
|
442
|
+
// left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
443
|
+
// top = triggerRect.top - SPACING;
|
|
444
|
+
left = isWidthOverFlow ? containerRect.left : (pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left);
|
|
445
|
+
top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
|
|
402
446
|
translateY = -1;
|
|
403
447
|
break;
|
|
404
448
|
case 'topRight':
|
|
405
|
-
left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
|
|
406
|
-
top = triggerRect.top - SPACING;
|
|
449
|
+
// left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
|
|
450
|
+
// top = triggerRect.top - SPACING;
|
|
451
|
+
left = isWidthOverFlow ? containerRect.right + offsetWidth : (pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right);
|
|
452
|
+
top = isHeightOverFlow ? containerRect.bottom + offsetHeight : triggerRect.top - SPACING;
|
|
407
453
|
translateY = -1;
|
|
408
454
|
translateX = -1;
|
|
409
455
|
break;
|
|
410
456
|
case 'left':
|
|
411
|
-
left = triggerRect.left - SPACING;
|
|
412
|
-
top = middleY;
|
|
457
|
+
// left = triggerRect.left - SPACING;
|
|
458
|
+
// top = middleY;
|
|
459
|
+
// left = isWidthOverFlow? containerRect.right - SPACING : triggerRect.left - SPACING;
|
|
460
|
+
left = isWidthOverFlow ? containerRect.right + offsetWidth - SPACING + offsetXWithArrow : triggerRect.left - SPACING;
|
|
461
|
+
top = isHeightOverFlow ? (isTriggerNearTop ? containerRect.top + wrapperRect.height / 2 : containerRect.bottom - wrapperRect.height / 2 + offsetHeight): middleY;
|
|
413
462
|
translateX = -1;
|
|
414
463
|
translateY = -0.5;
|
|
415
464
|
break;
|
|
416
465
|
case 'leftTop':
|
|
417
|
-
left = triggerRect.left - SPACING;
|
|
418
|
-
top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
466
|
+
// left = triggerRect.left - SPACING;
|
|
467
|
+
// top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
468
|
+
left = isWidthOverFlow ? containerRect.right + offsetWidth - SPACING + offsetXWithArrow : triggerRect.left - SPACING;
|
|
469
|
+
top = isHeightOverFlow ? containerRect.top : (pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top);
|
|
419
470
|
translateX = -1;
|
|
420
471
|
break;
|
|
421
472
|
case 'leftBottom':
|
|
422
|
-
left = triggerRect.left - SPACING;
|
|
423
|
-
top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
473
|
+
// left = triggerRect.left - SPACING;
|
|
474
|
+
// top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
475
|
+
left = isWidthOverFlow ? containerRect.right + offsetWidth - SPACING + offsetXWithArrow: triggerRect.left - SPACING;
|
|
476
|
+
top = isHeightOverFlow ? containerRect.bottom + offsetHeight: (pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom);
|
|
424
477
|
translateX = -1;
|
|
425
478
|
translateY = -1;
|
|
426
479
|
break;
|
|
427
480
|
case 'bottom':
|
|
428
|
-
left = middleX;
|
|
429
|
-
top = triggerRect.top + triggerRect.height + SPACING;
|
|
481
|
+
// left = middleX;
|
|
482
|
+
// top = triggerRect.top + triggerRect.height + SPACING;
|
|
483
|
+
left = isWidthOverFlow ? (isTriggerNearLeft ? containerRect.left + wrapperRect.width / 2 : containerRect.right - wrapperRect.width / 2 + offsetWidth): middleX;
|
|
484
|
+
top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING: triggerRect.top + triggerRect.height + SPACING;
|
|
430
485
|
translateX = -0.5;
|
|
431
486
|
break;
|
|
432
487
|
case 'bottomLeft':
|
|
433
|
-
left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
434
|
-
top = triggerRect.bottom + SPACING;
|
|
488
|
+
// left = pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left;
|
|
489
|
+
// top = triggerRect.bottom + SPACING;
|
|
490
|
+
left = isWidthOverFlow ? containerRect.left : (pointAtCenter ? middleX - offsetXWithArrow : triggerRect.left);
|
|
491
|
+
top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
|
|
435
492
|
break;
|
|
436
493
|
case 'bottomRight':
|
|
437
|
-
left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
|
|
438
|
-
top = triggerRect.bottom + SPACING;
|
|
494
|
+
// left = pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right;
|
|
495
|
+
// top = triggerRect.bottom + SPACING;
|
|
496
|
+
left = isWidthOverFlow ? containerRect.right + offsetWidth : (pointAtCenter ? middleX + offsetXWithArrow : triggerRect.right);
|
|
497
|
+
top = isHeightOverFlow ? containerRect.top + offsetYWithArrow - SPACING : triggerRect.top + triggerRect.height + SPACING;
|
|
439
498
|
translateX = -1;
|
|
440
499
|
break;
|
|
441
500
|
case 'right':
|
|
442
|
-
left = triggerRect.right + SPACING;
|
|
443
|
-
top = middleY;
|
|
501
|
+
// left = triggerRect.right + SPACING;
|
|
502
|
+
// top = middleY;
|
|
503
|
+
left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
|
|
504
|
+
top = isHeightOverFlow ? (isTriggerNearTop ? containerRect.top + wrapperRect.height / 2 : containerRect.bottom - wrapperRect.height / 2 + offsetHeight) : middleY;
|
|
444
505
|
translateY = -0.5;
|
|
445
506
|
break;
|
|
446
507
|
case 'rightTop':
|
|
447
|
-
left = triggerRect.right + SPACING;
|
|
448
|
-
top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
508
|
+
// left = triggerRect.right + SPACING;
|
|
509
|
+
// top = pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top;
|
|
510
|
+
left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
|
|
511
|
+
top = isHeightOverFlow ? containerRect.top : (pointAtCenter ? middleY - offsetYWithArrow : triggerRect.top);
|
|
449
512
|
break;
|
|
450
513
|
case 'rightBottom':
|
|
451
|
-
left = triggerRect.right + SPACING;
|
|
452
|
-
top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
514
|
+
// left = triggerRect.right + SPACING;
|
|
515
|
+
// top = pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom;
|
|
516
|
+
left = isWidthOverFlow ? containerRect.left - SPACING + offsetXWithArrow : triggerRect.right + SPACING;
|
|
517
|
+
top = isHeightOverFlow ? containerRect.bottom + offsetHeight : (pointAtCenter ? middleY + offsetYWithArrow : triggerRect.bottom);
|
|
453
518
|
translateY = -1;
|
|
454
519
|
break;
|
|
455
520
|
case 'leftTopOver':
|
|
@@ -574,18 +639,18 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
574
639
|
|
|
575
640
|
// console.log('containerRect: ', containerRect, 'triggerRect: ', triggerRect, 'wrapperRect: ', wrapperRect);
|
|
576
641
|
|
|
577
|
-
let style = this.calcPosStyle(triggerRect, wrapperRect, containerRect);
|
|
642
|
+
let style = this.calcPosStyle({ triggerRect, wrapperRect, containerRect });
|
|
578
643
|
|
|
579
644
|
let position = this.getProp('position');
|
|
580
645
|
|
|
581
646
|
if (this.getProp('autoAdjustOverflow')) {
|
|
582
647
|
// console.log('style: ', style, '\ntriggerRect: ', triggerRect, '\nwrapperRect: ', wrapperRect);
|
|
583
|
-
const adjustedPos = this.adjustPosIfNeed(position, style, triggerRect, wrapperRect, containerRect);
|
|
648
|
+
const { position: adjustedPos, isHeightOverFlow, isWidthOverFlow } = this.adjustPosIfNeed(position, style, triggerRect, wrapperRect, containerRect);
|
|
584
649
|
|
|
585
|
-
if (position !== adjustedPos) {
|
|
650
|
+
if (position !== adjustedPos || isHeightOverFlow || isWidthOverFlow) {
|
|
586
651
|
position = adjustedPos;
|
|
587
652
|
|
|
588
|
-
style = this.calcPosStyle(triggerRect, wrapperRect, containerRect, position);
|
|
653
|
+
style = this.calcPosStyle({ triggerRect, wrapperRect, containerRect, position, spacing: null, isOverFlow: [ isHeightOverFlow, isWidthOverFlow ] });
|
|
589
654
|
}
|
|
590
655
|
}
|
|
591
656
|
|
|
@@ -598,17 +663,66 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
598
663
|
};
|
|
599
664
|
|
|
600
665
|
isLR(position = '') {
|
|
601
|
-
return position.
|
|
666
|
+
return position.includes('left') || position.includes('right');
|
|
602
667
|
}
|
|
603
668
|
|
|
604
669
|
isTB(position = '') {
|
|
605
|
-
return position.
|
|
670
|
+
return position.includes('top') || position.includes('bottom');
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
isReverse(rowSpace: number, reverseSpace: number, size: number) {
|
|
674
|
+
// 原空间不足,反向空间足够
|
|
675
|
+
// Insufficient original space, enough reverse space
|
|
676
|
+
return rowSpace < size && reverseSpace > size;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
isOverFlow(rowSpace: number, reverseSpace: number, size: number){
|
|
680
|
+
// 原空间且反向空间都不足
|
|
681
|
+
// The original space and the reverse space are not enough
|
|
682
|
+
return rowSpace < size && reverseSpace < size;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
isHalfOverFlow(posSpace: number, negSpace: number, size: number){
|
|
686
|
+
// 正半空间或者负半空间不足,即表示有遮挡,需要偏移
|
|
687
|
+
// Insufficient positive half space or negative half space means that there is occlusion and needs to be offset
|
|
688
|
+
return posSpace < size || negSpace < size;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
isHalfAllEnough(posSpace: number, negSpace: number, size: number){
|
|
692
|
+
// 正半空间和负半空间都足够,即表示可以从 topLeft/topRight 变成 top
|
|
693
|
+
// Both positive and negative half-spaces are sufficient, which means you can change from topLeft/topRight to top
|
|
694
|
+
return posSpace >= size || negSpace >= size;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
getReverse(viewOverFlow: boolean, containerOverFlow: boolean, shouldReverseView: boolean, shouldReverseContainer: boolean) {
|
|
698
|
+
/**
|
|
699
|
+
* 基于视口和容器一起判断,以下几种情况允许从原方向转到反方向,以判断是否应该由top->bottom为例子
|
|
700
|
+
*
|
|
701
|
+
* 1. 视口上下空间不足 且 容器上空间❌下空间✅
|
|
702
|
+
* 2. 视口上空间❌下空间✅ 且 容器上下空间不足
|
|
703
|
+
* 3. 视口上空间❌下空间✅ 且 容器上空间❌下空间✅
|
|
704
|
+
*
|
|
705
|
+
* 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
|
|
706
|
+
* to judge whether it should be top->bottom as an example
|
|
707
|
+
* 1. There is insufficient space above and below the viewport and the space above the container ❌ the space below ✅
|
|
708
|
+
* 2. The space above the viewport ❌ the space below ✅ and the space above and below the container is insufficient
|
|
709
|
+
* 3. Viewport upper space ❌ lower space✅ and container upper space ❌ lower space✅
|
|
710
|
+
*/
|
|
711
|
+
return (viewOverFlow && shouldReverseContainer) || (shouldReverseView && containerOverFlow) || (shouldReverseView && shouldReverseContainer);
|
|
606
712
|
}
|
|
607
713
|
|
|
608
714
|
// place the dom correctly
|
|
609
715
|
adjustPosIfNeed(position: Position | string, style: Record<string, any>, triggerRect: DOMRect, wrapperRect: DOMRect, containerRect: PopupContainerDOMRect) {
|
|
610
716
|
const { innerWidth, innerHeight } = window;
|
|
611
|
-
const { spacing } = this.getProps();
|
|
717
|
+
const { spacing, margin } = this.getProps();
|
|
718
|
+
|
|
719
|
+
const marginLeft = typeof margin === 'number' ? margin : margin.marginLeft;
|
|
720
|
+
const marginTop = typeof margin === 'number' ? margin : margin.marginTop;
|
|
721
|
+
const marginRight = typeof margin === 'number' ? margin : margin.marginRight;
|
|
722
|
+
const marginBottom = typeof margin === 'number' ? margin : margin.marginBottom;
|
|
723
|
+
|
|
724
|
+
let isHeightOverFlow = false;
|
|
725
|
+
let isWidthOverFlow = false;
|
|
612
726
|
|
|
613
727
|
if (wrapperRect.width > 0 && wrapperRect.height > 0) {
|
|
614
728
|
// let clientLeft = left + translateX * wrapperRect.width - containerRect.scrollLeft;
|
|
@@ -638,144 +752,274 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
638
752
|
|
|
639
753
|
// The wrapperR ect.top|bottom equivalent cannot be directly used here for comparison, which is easy to cause jitter
|
|
640
754
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
const
|
|
755
|
+
// 基于视口的微调判断
|
|
756
|
+
// Fine-tuning judgment based on viewport
|
|
757
|
+
const shouldViewReverseTop = clientTop - marginTop < wrapperRect.height + spacing && restClientBottom - marginBottom > wrapperRect.height + spacing;
|
|
758
|
+
const shouldViewReverseLeft = clientLeft - marginLeft < wrapperRect.width + spacing && restClientRight - marginRight > wrapperRect.width + spacing;
|
|
759
|
+
const shouldViewReverseBottom = restClientBottom - marginBottom < wrapperRect.height + spacing && clientTop - marginTop > wrapperRect.height + spacing;
|
|
760
|
+
const shouldViewReverseRight = restClientRight - marginRight < wrapperRect.width + spacing && clientLeft - marginLeft > wrapperRect.width + spacing;
|
|
761
|
+
const shouldViewReverseTopOver = restClientTop - marginBottom< wrapperRect.height + spacing && clientBottom - marginTop> wrapperRect.height + spacing;
|
|
762
|
+
const shouldViewReverseBottomOver = clientBottom - marginTop < wrapperRect.height + spacing && restClientTop - marginBottom > wrapperRect.height + spacing;
|
|
763
|
+
|
|
764
|
+
const shouldViewReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
|
|
765
|
+
const shouldViewReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
|
|
766
|
+
const shouldViewReverseLeftSide = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
|
|
767
|
+
const shouldViewReverseRightSide = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
768
|
+
|
|
645
769
|
const shouldReverseTopOver = restClientTop < wrapperRect.height + spacing && clientBottom > wrapperRect.height + spacing;
|
|
646
770
|
const shouldReverseBottomOver = clientBottom < wrapperRect.height + spacing && restClientTop > wrapperRect.height + spacing;
|
|
647
771
|
|
|
648
|
-
const shouldReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
|
|
649
|
-
const shouldReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
|
|
650
|
-
const shouldReverseLeftSide = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
|
|
651
|
-
const shouldReverseRightSide = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
652
|
-
|
|
653
772
|
const shouldReverseLeftOver = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
|
|
654
773
|
const shouldReverseRightOver = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
655
774
|
|
|
775
|
+
// 基于容器的微调判断
|
|
776
|
+
// Fine-tuning judgment based on container
|
|
777
|
+
const clientTopInContainer = clientTop - containerRect.top;
|
|
778
|
+
const clientLeftInContainer = clientLeft - containerRect.left;
|
|
779
|
+
const clientBottomInContainer = clientTopInContainer + triggerRect.height;
|
|
780
|
+
const clientRightInContainer = clientLeftInContainer + triggerRect.width;
|
|
781
|
+
|
|
782
|
+
const restClientBottomInContainer = containerRect.bottom - clientBottom;
|
|
783
|
+
const restClientRightInContainer = containerRect.right - clientRight;
|
|
784
|
+
const restClientTopInContainer = restClientBottomInContainer + triggerRect.height;
|
|
785
|
+
const restClientLeftInContainer = restClientRightInContainer + triggerRect.width;
|
|
786
|
+
|
|
787
|
+
// 当原空间不足,反向空间足够时,可以反向。
|
|
788
|
+
// When the original space is insufficient and the reverse space is sufficient, the reverse can be performed.
|
|
789
|
+
const shouldContainerReverseTop = this.isReverse(clientTopInContainer - marginTop, restClientBottomInContainer - marginBottom, wrapperRect.height + spacing);
|
|
790
|
+
const shouldContainerReverseLeft = this.isReverse(clientLeftInContainer - marginLeft, restClientRightInContainer - marginRight, wrapperRect.width + spacing);
|
|
791
|
+
const shouldContainerReverseBottom = this.isReverse(restClientBottomInContainer - marginBottom, clientTopInContainer - marginTop, wrapperRect.height + spacing);
|
|
792
|
+
const shouldContainerReverseRight = this.isReverse(restClientRightInContainer - marginRight, clientLeftInContainer - marginLeft, wrapperRect.width + spacing);
|
|
793
|
+
const shouldContainerReverseTopOver = this.isReverse(restClientTopInContainer - marginBottom, clientBottomInContainer - marginTop, wrapperRect.height + spacing);
|
|
794
|
+
const shouldContainerReverseBottomOver = this.isReverse(clientBottomInContainer - marginTop, restClientTopInContainer - marginBottom, wrapperRect.height + spacing);
|
|
795
|
+
|
|
796
|
+
const shouldContainerReverseTopSide = this.isReverse(restClientTopInContainer, clientBottomInContainer, wrapperRect.height);
|
|
797
|
+
const shouldContainerReverseBottomSide = this.isReverse(clientBottomInContainer, restClientTopInContainer, wrapperRect.height);
|
|
798
|
+
const shouldContainerReverseLeftSide = this.isReverse(restClientLeftInContainer, clientRightInContainer, wrapperRect.width);
|
|
799
|
+
const shouldContainerReverseRightSide = this.isReverse(clientRightInContainer, restClientLeftInContainer, wrapperRect.width);
|
|
800
|
+
|
|
801
|
+
const halfHeight = triggerRect.height / 2;
|
|
802
|
+
const halfWidth = triggerRect.width / 2;
|
|
803
|
+
|
|
804
|
+
// 视口, 原空间与反向空间是否都不足判断
|
|
805
|
+
// Viewport, whether the original space and the reverse space are insufficient to judge
|
|
806
|
+
const isViewYOverFlow = this.isOverFlow(clientTop - marginTop, restClientBottom - marginBottom, wrapperRect.height + spacing);
|
|
807
|
+
const isViewXOverFlow = this.isOverFlow(clientLeft - marginLeft, restClientRight - marginRight, wrapperRect.width + spacing);
|
|
808
|
+
const isViewYOverFlowSide = this.isOverFlow(clientBottom - marginTop, restClientTop - marginBottom, wrapperRect.height + spacing);
|
|
809
|
+
const isViewXOverFlowSide = this.isOverFlow(clientRight - marginLeft, restClientLeft - marginRight, wrapperRect.width + spacing);
|
|
810
|
+
const isViewYOverFlowSideHalf = this.isHalfOverFlow(clientBottom - halfHeight, restClientTop - halfHeight, wrapperRect.height / 2);
|
|
811
|
+
const isViewXOverFlowSideHalf = this.isHalfOverFlow(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2);
|
|
812
|
+
const isViewYEnoughSideHalf = this.isHalfAllEnough(clientBottom - halfHeight, restClientTop - halfHeight, wrapperRect.height / 2);
|
|
813
|
+
const isViewXEnoughSideHalf = this.isHalfAllEnough(clientRight - halfWidth, restClientLeft - halfWidth, wrapperRect.width / 2);
|
|
814
|
+
|
|
815
|
+
// 容器, 原空间与反向空间是否都不足判断
|
|
816
|
+
// container, whether the original space and the reverse space are insufficient to judge
|
|
817
|
+
const isContainerYOverFlow = this.isOverFlow(clientTopInContainer - marginTop, restClientBottomInContainer - marginBottom, wrapperRect.height + spacing);
|
|
818
|
+
const isContainerXOverFlow = this.isOverFlow(clientLeftInContainer - marginLeft, restClientRightInContainer - marginRight, wrapperRect.width + spacing);
|
|
819
|
+
const isContainerYOverFlowSide = this.isOverFlow(clientBottomInContainer - marginTop, restClientTopInContainer - marginBottom, wrapperRect.height + spacing);
|
|
820
|
+
const isContainerXOverFlowSide = this.isOverFlow(clientRightInContainer - marginLeft, restClientLeftInContainer - marginRight, wrapperRect.width + spacing);
|
|
821
|
+
const isContainerYOverFlowSideHalf = this.isHalfOverFlow(clientBottomInContainer - halfHeight, restClientTopInContainer - halfHeight, wrapperRect.height / 2);
|
|
822
|
+
const isContainerXOverFlowSideHalf = this.isHalfOverFlow(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2);
|
|
823
|
+
const isContainerYEnoughSideHalf = this.isHalfAllEnough(clientBottomInContainer - halfHeight, restClientTopInContainer - halfHeight, wrapperRect.height / 2);
|
|
824
|
+
const isContainerXEnoughSideHalf = this.isHalfAllEnough(clientRightInContainer - halfWidth, restClientLeftInContainer - halfWidth, wrapperRect.width / 2);
|
|
825
|
+
|
|
826
|
+
// 综合 viewport + container 判断微调,即视口 + 容器都放置不行时才能考虑位置调整
|
|
827
|
+
// Comprehensive viewport + container judgment fine-tuning, that is, the position adjustment can only be considered when the viewport + container cannot be placed.
|
|
828
|
+
const shouldReverseTop = this.getReverse(isViewYOverFlow, isContainerYOverFlow, shouldViewReverseTop, shouldContainerReverseTop);
|
|
829
|
+
const shouldReverseLeft = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseLeft, shouldContainerReverseLeft);
|
|
830
|
+
const shouldReverseBottom = this.getReverse(isViewYOverFlow, isContainerYOverFlow, shouldViewReverseBottom, shouldContainerReverseBottom);
|
|
831
|
+
const shouldReverseRight = this.getReverse(isViewXOverFlow, isContainerXOverFlow, shouldViewReverseRight, shouldContainerReverseRight);
|
|
832
|
+
|
|
833
|
+
// const shouldReverseTopOver = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseTopOver, shouldContainerReverseTopOver);
|
|
834
|
+
// const shouldReverseBottomOver = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseBottomOver, shouldContainerReverseBottomOver);
|
|
835
|
+
|
|
836
|
+
const shouldReverseTopSide = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseTopSide, shouldContainerReverseTopSide);
|
|
837
|
+
const shouldReverseBottomSide = this.getReverse(isViewYOverFlowSide, isContainerYOverFlowSide, shouldViewReverseBottomSide, shouldContainerReverseBottomSide);
|
|
838
|
+
const shouldReverseLeftSide = this.getReverse(isViewXOverFlowSide, isContainerXOverFlowSide, shouldViewReverseLeftSide, shouldContainerReverseLeftSide);
|
|
839
|
+
const shouldReverseRightSide = this.getReverse(isViewXOverFlowSide, isContainerXOverFlowSide, shouldViewReverseRightSide, shouldContainerReverseRightSide);
|
|
840
|
+
|
|
841
|
+
const isYOverFlowSideHalf = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
|
|
842
|
+
const isXOverFlowSideHalf = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
|
|
843
|
+
|
|
656
844
|
switch (position) {
|
|
657
845
|
case 'top':
|
|
658
846
|
if (shouldReverseTop) {
|
|
659
|
-
position = this.
|
|
847
|
+
position = this._adjustPos(position, true);
|
|
848
|
+
}
|
|
849
|
+
if (isXOverFlowSideHalf && (shouldReverseLeftSide || shouldReverseRightSide)) {
|
|
850
|
+
position = this._adjustPos(position, true, 'expand', shouldReverseLeftSide ? 'Right' : 'Left');
|
|
660
851
|
}
|
|
661
852
|
break;
|
|
662
853
|
case 'topLeft':
|
|
663
854
|
if (shouldReverseTop) {
|
|
664
|
-
position = this.
|
|
855
|
+
position = this._adjustPos(position, true);
|
|
665
856
|
}
|
|
666
857
|
if (shouldReverseLeftSide && widthIsBigger) {
|
|
667
|
-
position = this.
|
|
858
|
+
position = this._adjustPos(position, true);
|
|
859
|
+
}
|
|
860
|
+
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
861
|
+
position = this._adjustPos(position, true, 'reduce');
|
|
668
862
|
}
|
|
669
863
|
break;
|
|
670
864
|
case 'topRight':
|
|
671
865
|
if (shouldReverseTop) {
|
|
672
|
-
position = this.
|
|
866
|
+
position = this._adjustPos(position, true);
|
|
673
867
|
}
|
|
674
868
|
if (shouldReverseRightSide && widthIsBigger) {
|
|
675
|
-
position = this.
|
|
869
|
+
position = this._adjustPos(position);
|
|
870
|
+
}
|
|
871
|
+
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
872
|
+
position = this._adjustPos(position, true, 'reduce');
|
|
676
873
|
}
|
|
677
874
|
break;
|
|
678
875
|
case 'left':
|
|
679
876
|
if (shouldReverseLeft) {
|
|
680
|
-
position = this.
|
|
877
|
+
position = this._adjustPos(position);
|
|
878
|
+
}
|
|
879
|
+
if (isYOverFlowSideHalf && (shouldReverseTopSide || shouldReverseBottomSide)) {
|
|
880
|
+
position = this._adjustPos(position, false, 'expand', shouldReverseTopSide ? 'Bottom' : 'Top');
|
|
681
881
|
}
|
|
682
882
|
break;
|
|
683
883
|
case 'leftTop':
|
|
684
884
|
if (shouldReverseLeft) {
|
|
685
|
-
position = this.
|
|
885
|
+
position = this._adjustPos(position);
|
|
686
886
|
}
|
|
687
887
|
if (shouldReverseTopSide && heightIsBigger) {
|
|
688
|
-
position = this.
|
|
888
|
+
position = this._adjustPos(position, true);
|
|
889
|
+
}
|
|
890
|
+
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
891
|
+
position = this._adjustPos(position, false, 'reduce');
|
|
689
892
|
}
|
|
690
893
|
break;
|
|
691
894
|
case 'leftBottom':
|
|
692
895
|
if (shouldReverseLeft) {
|
|
693
|
-
position = this.
|
|
896
|
+
position = this._adjustPos(position);
|
|
694
897
|
}
|
|
695
898
|
if (shouldReverseBottomSide && heightIsBigger) {
|
|
696
|
-
position = this.
|
|
899
|
+
position = this._adjustPos(position, true);
|
|
900
|
+
}
|
|
901
|
+
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
902
|
+
position = this._adjustPos(position, false, 'reduce');
|
|
697
903
|
}
|
|
698
904
|
break;
|
|
699
905
|
case 'bottom':
|
|
700
906
|
if (shouldReverseBottom) {
|
|
701
|
-
position = this.
|
|
907
|
+
position = this._adjustPos(position, true);
|
|
908
|
+
}
|
|
909
|
+
if (isXOverFlowSideHalf && (shouldReverseLeftSide || shouldReverseRightSide)) {
|
|
910
|
+
position = this._adjustPos(position, true, 'expand', shouldReverseLeftSide ? 'Right' : 'Left');
|
|
702
911
|
}
|
|
703
912
|
break;
|
|
704
913
|
case 'bottomLeft':
|
|
705
914
|
if (shouldReverseBottom) {
|
|
706
|
-
position = this.
|
|
915
|
+
position = this._adjustPos(position, true);
|
|
707
916
|
}
|
|
708
917
|
if (shouldReverseLeftSide && widthIsBigger) {
|
|
709
|
-
position = this.
|
|
918
|
+
position = this._adjustPos(position);
|
|
919
|
+
}
|
|
920
|
+
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
921
|
+
position = this._adjustPos(position, true, 'reduce');
|
|
710
922
|
}
|
|
711
923
|
break;
|
|
712
924
|
case 'bottomRight':
|
|
713
925
|
if (shouldReverseBottom) {
|
|
714
|
-
position = this.
|
|
926
|
+
position = this._adjustPos(position, true);
|
|
715
927
|
}
|
|
716
928
|
if (shouldReverseRightSide && widthIsBigger) {
|
|
717
|
-
position = this.
|
|
929
|
+
position = this._adjustPos(position);
|
|
930
|
+
}
|
|
931
|
+
if (isWidthOverFlow && (isViewXEnoughSideHalf || isContainerXEnoughSideHalf)) {
|
|
932
|
+
position = this._adjustPos(position, true, 'reduce');
|
|
718
933
|
}
|
|
719
934
|
break;
|
|
720
935
|
case 'right':
|
|
721
936
|
if (shouldReverseRight) {
|
|
722
|
-
position = this.
|
|
937
|
+
position = this._adjustPos(position);
|
|
938
|
+
}
|
|
939
|
+
if (isYOverFlowSideHalf && (shouldReverseTopSide || shouldReverseBottomSide)) {
|
|
940
|
+
position = this._adjustPos(position, false, 'expand', shouldReverseTopSide ? 'Bottom' : 'Top');
|
|
723
941
|
}
|
|
724
942
|
break;
|
|
725
943
|
case 'rightTop':
|
|
726
944
|
if (shouldReverseRight) {
|
|
727
|
-
position = this.
|
|
945
|
+
position = this._adjustPos(position);
|
|
728
946
|
}
|
|
729
947
|
if (shouldReverseTopSide && heightIsBigger) {
|
|
730
|
-
position = this.
|
|
948
|
+
position = this._adjustPos(position, true);
|
|
949
|
+
}
|
|
950
|
+
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
951
|
+
position = this._adjustPos(position, false, 'reduce');
|
|
731
952
|
}
|
|
732
953
|
break;
|
|
733
954
|
case 'rightBottom':
|
|
734
955
|
if (shouldReverseRight) {
|
|
735
|
-
position = this.
|
|
956
|
+
position = this._adjustPos(position);
|
|
736
957
|
}
|
|
737
958
|
if (shouldReverseBottomSide && heightIsBigger) {
|
|
738
|
-
position = this.
|
|
959
|
+
position = this._adjustPos(position, true);
|
|
960
|
+
}
|
|
961
|
+
if (isHeightOverFlow && (isViewYEnoughSideHalf || isContainerYEnoughSideHalf)) {
|
|
962
|
+
position = this._adjustPos(position, false, 'reduce');
|
|
739
963
|
}
|
|
740
964
|
break;
|
|
741
965
|
case 'leftTopOver':
|
|
742
966
|
if (shouldReverseTopOver) {
|
|
743
|
-
position = this.
|
|
967
|
+
position = this._adjustPos(position, true);
|
|
744
968
|
}
|
|
745
969
|
if (shouldReverseLeftOver) {
|
|
746
|
-
position = this.
|
|
970
|
+
position = this._adjustPos(position);
|
|
747
971
|
}
|
|
748
972
|
break;
|
|
749
973
|
case 'leftBottomOver':
|
|
750
974
|
if (shouldReverseBottomOver) {
|
|
751
|
-
position = this.
|
|
975
|
+
position = this._adjustPos(position, true);
|
|
752
976
|
}
|
|
753
977
|
if (shouldReverseLeftOver) {
|
|
754
|
-
position = this.
|
|
978
|
+
position = this._adjustPos(position);
|
|
755
979
|
}
|
|
756
980
|
break;
|
|
757
981
|
case 'rightTopOver':
|
|
758
982
|
if (shouldReverseTopOver) {
|
|
759
|
-
position = this.
|
|
983
|
+
position = this._adjustPos(position, true);
|
|
760
984
|
}
|
|
761
985
|
if (shouldReverseRightOver) {
|
|
762
|
-
position = this.
|
|
986
|
+
position = this._adjustPos(position);
|
|
763
987
|
}
|
|
764
988
|
break;
|
|
765
989
|
case 'rightBottomOver':
|
|
766
990
|
if (shouldReverseBottomOver) {
|
|
767
|
-
position = this.
|
|
991
|
+
position = this._adjustPos(position, true);
|
|
768
992
|
}
|
|
769
993
|
if (shouldReverseRightOver) {
|
|
770
|
-
position = this.
|
|
994
|
+
position = this._adjustPos(position);
|
|
771
995
|
}
|
|
772
996
|
break;
|
|
773
997
|
default:
|
|
774
998
|
break;
|
|
775
999
|
}
|
|
1000
|
+
|
|
1001
|
+
// 判断溢出 Judgment overflow
|
|
1002
|
+
// 上下方向 top and bottom
|
|
1003
|
+
if (this.isTB(position)){
|
|
1004
|
+
isHeightOverFlow = isViewYOverFlow && isContainerYOverFlow;
|
|
1005
|
+
if (position === 'top' || position === 'bottom') {
|
|
1006
|
+
isWidthOverFlow = isViewXOverFlowSideHalf && isContainerXOverFlowSideHalf;
|
|
1007
|
+
} else {
|
|
1008
|
+
isWidthOverFlow = isViewXOverFlowSide && isContainerXOverFlowSide;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
// 左右方向 left and right
|
|
1012
|
+
if (this.isLR(position)){
|
|
1013
|
+
isWidthOverFlow = isViewXOverFlow && isContainerXOverFlow;
|
|
1014
|
+
if (position === 'left' || position === 'right') {
|
|
1015
|
+
isHeightOverFlow = isViewYOverFlowSideHalf && isContainerYOverFlowSideHalf;
|
|
1016
|
+
} else {
|
|
1017
|
+
isHeightOverFlow = isViewYOverFlowSide && isContainerYOverFlowSide;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
776
1020
|
}
|
|
777
1021
|
|
|
778
|
-
return position;
|
|
1022
|
+
return { position, isHeightOverFlow, isWidthOverFlow };
|
|
779
1023
|
}
|
|
780
1024
|
|
|
781
1025
|
delayHide = () => {
|
package/transfer/animation.scss
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
$transition_duration_transfer_item-bg: var(--semi-transition_duration-
|
|
1
|
+
$transition_duration_transfer_item-bg: var(--semi-transition_duration-none);//穿梭框条目-背景色-动画持续时间
|
|
2
2
|
$transition_function_transfer_item-bg: var(--semi-transition_function-easeIn);//穿梭框条目-背景色-过渡曲线
|
|
3
|
-
$transition_delay_transfer_item-bg: var(--semi-transition_delay-
|
|
3
|
+
$transition_delay_transfer_item-bg: var(--semi-transition_delay-none);//穿梭框条目-背景色-延迟时间
|
|
4
4
|
|
package/tree/animation.scss
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
$transition_duration-tree_option-bg: var(--semi-transition_duration-
|
|
1
|
+
$transition_duration-tree_option-bg: var(--semi-transition_duration-none);//树选项-背景色-动画持续时间
|
|
2
2
|
$transition_function-tree_option-bg: var(--semi-transition_function-easeIn);//树选项-背景色-过渡曲线
|
|
3
|
-
$transition_delay-tree_option-bg: var(--semi-transition_delay-
|
|
3
|
+
$transition_delay-tree_option-bg: var(--semi-transition_delay-none);//树选项-背景色-延迟时间
|
|
4
4
|
|
|
5
5
|
//transform token
|
|
6
6
|
|