Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/utils/src/popper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,17 +703,18 @@ export class PopperJS {
let center = reference[side] + (arrowOffset || reference[calcProp] / 2 - arrowSize / 2)
let sideValue = center - popper[side]

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

// adjustArrow此处还要校正一下,但不明白为什么只校正left, 不校正top的位置?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adjustment logic for the arrow position only considers the 'left' side when adjustArrow is true and the placement is 'top' or 'bottom'. Ensure that this logic is correct and that 'top' adjustments are not needed in this context.

const params = this._options.placement.split('-')
if (this._options.adjustArrow && ~['top', 'bottom'].indexOf(params[0]) && side === 'left') {
if (params[1] === 'start') {
arrowStyle.left = 8
arrowStyle.left = safeLeft
} else if (!params[1]) {
arrowStyle.left = (popperRect.width - arrowRect.width) / 2
}
Expand Down
Loading