Merge branch 'develop' of ***REMOVED*** into develop

This commit is contained in:
07akioni 2020-01-15 15:30:15 +08:00
commit 3a35c4eaff
4 changed files with 14 additions and 8 deletions

View File

@ -4,7 +4,7 @@
<div <div
v-if="showLightBar" v-if="showLightBar"
class="n-base-select-menu-light-bar" class="n-base-select-menu-light-bar"
:style="{ top: `${lightBarTop}px` }" :style="{ top: lightBarStyleTop }"
/> />
</transition> </transition>
</div> </div>

View File

@ -55,7 +55,6 @@ export default {
}, },
mounted () { mounted () {
if (this.detached) { if (this.detached) {
this.detachTarget = document.body // getScrollParent(this.$refs.self)
this.detachContent() this.detachContent()
if (this.active && !this.contentContainerMounted) { if (this.active && !this.contentContainerMounted) {
this.contentContainerMounted = true this.contentContainerMounted = true

View File

@ -205,6 +205,7 @@ export default {
updatePosition (el, cb) { updatePosition (el, cb) {
if (!this.active && !this.show) return if (!this.active && !this.show) return
this._getTrackingElement() this._getTrackingElement()
this.trackingElement.style.position = 'absolute'
if (this.manuallyPositioned) { if (this.manuallyPositioned) {
if (!this.trackingElement) { if (!this.trackingElement) {
console.error('[naive-ui/placeable/updatePosition]: trackingElement not found!') console.error('[naive-ui/placeable/updatePosition]: trackingElement not found!')
@ -218,6 +219,10 @@ export default {
} }
} }
const activatorRect = getActivatorRect(this.manuallyPositioned, this.x, this.y, this.trackedElement) const activatorRect = getActivatorRect(this.manuallyPositioned, this.x, this.y, this.trackedElement)
const contentInner = getContentInner(this)
if (this.widthMode === 'activator' && contentInner) {
contentInner.style.minWidth = activatorRect.width + 'px'
}
const contentBoundingClientRect = { const contentBoundingClientRect = {
width: this.trackingElement.offsetWidth, width: this.trackingElement.offsetWidth,
height: this.trackingElement.offsetHeight height: this.trackingElement.offsetHeight
@ -230,10 +235,6 @@ export default {
offset = getPositionInAbsoluteMode(adjustedPlacement) offset = getPositionInAbsoluteMode(adjustedPlacement)
} }
this.setOffsetOfTrackingElement(offset, suggestedTransformOrigin) this.setOffsetOfTrackingElement(offset, suggestedTransformOrigin)
const contentInner = getContentInner(this)
if (this.widthMode === 'activator' && contentInner) {
contentInner.style.minWidth = activatorRect.width + 'px'
}
if (el && cb) { if (el && cb) {
cb(el, activatorRect, contentBoundingClientRect) cb(el, activatorRect, contentBoundingClientRect)
} }

View File

@ -57,8 +57,14 @@ export function getAdjustedPlacementOfTrackingElement (placement = 'bottom-start
let adjustedPosition = position let adjustedPosition = position
if (position) { if (position) {
const adjacentPositionDirection = positionDirections[placement] const adjacentPositionDirection = positionDirections[placement]
if (trackedRect[adjacentPositionDirection] + trackedRect[lengthToCompare[adjacentPositionDirection]] <= trackingRect[lengthToCompare[adjacentPositionDirection]]) { if (trackingRect[lengthToCompare[adjacentPositionDirection]] > trackedRect[lengthToCompare[adjacentPositionDirection]]) {
adjustedPosition = oppositePosition[position] if (trackedRect[adjacentPositionDirection] + trackedRect[lengthToCompare[adjacentPositionDirection]] <= trackingRect[lengthToCompare[adjacentPositionDirection]]) {
adjustedPosition = oppositePosition[position]
}
} else if (trackingRect[lengthToCompare[adjacentPositionDirection]] < trackedRect[lengthToCompare[adjacentPositionDirection]]) {
if (trackedRect[oppositeDirection[adjacentPositionDirection]] < 0 && trackedRect[adjacentPositionDirection] > 0) {
adjustedPosition = oppositePosition[position]
}
} }
} }
if (trackedRect[direction] >= trackingRect[lengthToCompare[direction]]) { if (trackedRect[direction] >= trackingRect[lengthToCompare[direction]]) {