refactor(popover): use manual trigger when x and y is set

This commit is contained in:
07akioni 2021-07-29 00:36:11 +08:00
parent 12a8381236
commit 6b2b15d4d7

View File

@ -14,7 +14,7 @@ import {
} from 'vue'
import { VBinder, VTarget, FollowerPlacement } from 'vueuc'
import { useMergedState, useCompitable, useIsMounted, useMemo } from 'vooks'
import { call, keep, warn, getFirstSlotVNode, throwError } from '../../_utils'
import { call, keep, warn, getFirstSlotVNode } from '../../_utils'
import type {
ExtractPublicPropTypes,
ExtractInternalPropTypes,
@ -231,16 +231,6 @@ export default defineComponent({
const showTimerIdRef = ref<number | null>(null)
const hideTimerIdRef = ref<number | null>(null)
const positionManuallyRef = useMemo(() => {
if (
props.x !== undefined &&
props.y !== undefined &&
props.trigger !== 'manual'
) {
throwError(
'popover',
"Set the 'trigger' prop to 'manual', when you want to manually positioned."
)
}
return props.x !== undefined && props.y !== undefined
})
// methods
@ -410,7 +400,7 @@ export default defineComponent({
triggerVNode.type === textVNodeType
? h('span', [triggerVNode])
: triggerVNode
appendEvents(triggerVNode, this.trigger, {
appendEvents(triggerVNode, positionManually ? 'manual' : this.trigger, {
onClick: this.handleClick,
onMouseenter: this.handleMouseEnter,
onMouseleave: this.handleMouseLeave,