Skip to content

Commit 466ba0b

Browse files
authored
fix(utils): fix tooltip arrow safe padding (#3354)
1 parent 5c9f4e3 commit 466ba0b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/utils/src/popper/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,17 +703,18 @@ export class PopperJS {
703703
let center = reference[side] + (arrowOffset || reference[calcProp] / 2 - arrowSize / 2)
704704
let sideValue = center - popper[side]
705705

706-
// 猜测是上下边距留下8px的距离。 确保箭头不太靠顶靠底。
707-
// 此时sideValue为“popper的顶- 箭头 - 8px” 的位置。
708-
sideValue = Math.max(Math.min(popper[calcProp] - arrowSize - 8, sideValue), 8)
706+
// 猜测是上下边距留下4px的距离。 确保箭头不太靠顶靠底。
707+
// 此时sideValue为“popper的顶- 箭头 - 4px” 的位置。
708+
const safeLeft = 4
709+
sideValue = Math.max(Math.min(popper[calcProp] - arrowSize - safeLeft, sideValue), safeLeft)
709710
arrowStyle[side] = sideValue
710711
arrowStyle[altSide] = ''
711712

712713
// adjustArrow此处还要校正一下,但不明白为什么只校正left, 不校正top的位置?
713714
const params = this._options.placement.split('-')
714715
if (this._options.adjustArrow && ~['top', 'bottom'].indexOf(params[0]) && side === 'left') {
715716
if (params[1] === 'start') {
716-
arrowStyle.left = 8
717+
arrowStyle.left = safeLeft
717718
} else if (!params[1]) {
718719
arrowStyle.left = (popperRect.width - arrowRect.width) / 2
719720
}

0 commit comments

Comments
 (0)