Skip to content

usePopoverContent

根据 open / side / sideOffset 等选项,生成供 motion-v 使用的 initial / animate / transition(返回值为 ComputedRef)。

Installation

pnpm dlx @weme-ui/weme-ui add weme-ui/slim/use-popover-content

Usage

import { ref } from 'vue'
import { usePopoverContent } from '~/composables/use-popover-content'

const open = ref(false)
const motion = usePopoverContent({
  open,
  height: 200,
  side: 'bottom',
  sideOffset: 6,
})

// motion.value.initial / animate / transition

Returns

ComputedRef<UsePopoverContentReturn>:

FieldType
initialOptions['initial']
初始:height: 0、opacity: 0、y: 0
Options['initial']
animateOptions['animate']
打开时高度 / 透明度 / 按 side 的 y 偏移
Options['animate']
transitionOptions['transition']
spring:duration: 0.5、bounce: 0.2
Options['transition']

Options

UsePopoverContentOptions(均可选):

FieldType
openRef<boolean>
是否打开
Ref<boolean>
heightMaybeRefOrGetter<number | 'auto'>
展开高度;关闭时按 0 处理
MaybeRefOrGetter<number | 'auto'>
sideMaybeRefOrGetter<PopoverContentSide>
弹出方向
MaybeRefOrGetter<PopoverContentSide>
sideOffsetMaybeRefOrGetter<number>
沿 side 的位移偏移
MaybeRefOrGetter<number>

Types

PopoverContentSide

'top' | 'bottom' | 'left' | 'right'

UsePopoverContentOptions

见上方 Options。

UsePopoverContentReturn

见上方 Returns。

Files

  • src/composables/use-popover-content.ts