Skip to content
On this page

useElementBounding

动态获取 Dom 元素的尺寸、坐标。

代码演示

API

const isHovering = useHover(target, {
  reset?: boolean
  windowResize?: boolean
  windowScroll?: boolean
  immediate?: boolean
})
const isHovering = useHover(target, {
  reset?: boolean
  windowResize?: boolean
  windowScroll?: boolean
  immediate?: boolean
})

Params

参数说明类型默认值
targetDOM 节点或者 Ref 对象() => Element | Element | JSX.Element-
options额外的配置项UseElementBoundingOptions-

Options

参数说明类型默认值
reset当组件为挂载时,将所有值初始化为 0booleantrue
windowResize监听窗口尺寸变化booleantrue
windowScroll监听窗口滚动变化booleantrue
immediate组件挂载时立即执行booleantrue

Source

源码文档示例