mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-12 12:25:16 +08:00
fix(popover): fix popover arrow direction
This commit is contained in:
parent
90fb7ea091
commit
e066e195e0
@ -253,7 +253,7 @@ export default {
|
||||
this.active
|
||||
? h('div', {
|
||||
attrs: {
|
||||
'n-placement': this.placement
|
||||
'n-placement': this.adjustedPlacement
|
||||
},
|
||||
staticClass: 'n-popover-content',
|
||||
class: {
|
||||
|
@ -144,7 +144,8 @@ export default {
|
||||
return {
|
||||
trackingElement: null,
|
||||
trackedElement: null,
|
||||
scrollListeners: []
|
||||
scrollListeners: [],
|
||||
adjustedPlacement: this.placement
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@ -233,15 +234,13 @@ export default {
|
||||
// console.log(contentBoundingClientRect)
|
||||
// debugger
|
||||
// console.log('scroll', activatorBoundingClientRect, contentBoundingClientRect)
|
||||
const [placementTransform, suggestedTransformOrigin] = calcPlacementTransfrom(this.placement, activatorBoundingClientRect, contentBoundingClientRect, this.flip)
|
||||
// console.log(this.trackingElement, this.positionMode, this.positionModeisAbsolute)
|
||||
const [placementTransform, suggestedTransformOrigin, adjustedPlacement] = calcPlacementTransfrom(this.placement, activatorBoundingClientRect, contentBoundingClientRect, this.flip)
|
||||
this.adjustedPlacement = adjustedPlacement
|
||||
if (this.positionModeisAbsolute) {
|
||||
const position = getPositionInAbsoluteMode(this.placement, suggestedTransformOrigin)
|
||||
// console.log(suggestedTransformOrigin, position)
|
||||
this.updatePositionInAbsoluteMode(position, suggestedTransformOrigin)
|
||||
return
|
||||
}
|
||||
// console.log(placementTransform)
|
||||
this.trackingElement.style.position = 'absolute'
|
||||
this.trackingElement.style.top = placementTransform.top
|
||||
this.trackingElement.style.left = placementTransform.left
|
||||
|
@ -37,13 +37,13 @@ function getAdjustedPlacementOfTrackingElement (placement = 'bottom-start', trac
|
||||
}
|
||||
}
|
||||
if (trackedRect[direction] >= trackingRect[lengthToCompare[direction]]) {
|
||||
return direction + '-' + newPosition
|
||||
return newPosition ? (direction + '-' + newPosition) : direction
|
||||
} else if (trackedRect[oppositeDirection[direction]] >= trackingRect[lengthToCompare[direction]]) {
|
||||
if (position) {
|
||||
return `${oppositeDirection[direction]}-${newPosition}`
|
||||
} else return oppositeDirection[direction]
|
||||
} else {
|
||||
return direction + '-' + newPosition
|
||||
return newPosition ? (direction + '-' + newPosition) : direction
|
||||
}
|
||||
// else {
|
||||
// const [direction1, direction2] = adjacentDirections[direction]
|
||||
@ -157,7 +157,7 @@ function calcPlacementTransform (placement, activatorRect, contentRect, flip) {
|
||||
const adjustedPlacement = getAdjustedPlacementOfTrackingElement(placement, trackedRect, trackingRect, flip)
|
||||
const suggesetedTransfromOrigin = getTransformOriginByPlacement(adjustedPlacement)
|
||||
const position = getPosition(adjustedPlacement, trackedRect, trackingRect)
|
||||
return [position, suggesetedTransfromOrigin]
|
||||
return [position, suggesetedTransfromOrigin, adjustedPlacement]
|
||||
}
|
||||
|
||||
export default calcPlacementTransform
|
||||
|
Loading…
Reference in New Issue
Block a user