📜  在反应中获取元素的位置 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:18.110000             🧑  作者: Mango

代码示例1
showBanner(e) {
  const rect = this.btnDownload.current.getBoundingClientRect()

  const isInView = rect.top < window.innerHeight
  const isAtTop = rect.top <= 0

  console.log('Is in view:', isInView)
  console.log('Is at top:', isAtTop)
}