跳到正文

useLongPress ​

为触摸或指针交互提供长按手势状态与事件。

导入与签名 ​

ts
import { useLongPress } from '@easemob-community/uikit-im'

const gesture = useLongPress(callback, options)

参数 ​

参数类型默认值说明
callback() => void—达到长按时长后触发
options.delaynumber600长按时长(ms)
options.moveThresholdnumber10允许移动距离
options.preventScrollbooleantrue是否阻止长按过程滚动
options.onStart / onEnd回调—手势开始与结束

返回值 ​

返回 start、move、end、cancel 事件处理器和 isPressing 状态。

最小用法 ​

ts
const { start, move, end, isPressing } = useLongPress(() => {
  openMessageActions()
})